@teambit/lister 1.0.108 → 1.0.110
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/artifacts/preview/teambit_component_lister-preview.js +1 -0
- package/package.json +14 -10
- package/index.ts +0 -5
- package/list-template.ts +0 -77
- package/list.cmd.ts +0 -82
- package/lister.aspect.ts +0 -5
- package/lister.main.runtime.ts +0 -76
- /package/dist/{preview-1703647408454.js → preview-1703733956734.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports["teambit.component/lister-preview"]=o():e["teambit.component/lister-preview"]=o()}(self,(()=>(()=>{"use strict";var e={d:(o,t)=>{for(var r in t)e.o(t,r)&&!e.o(o,r)&&Object.defineProperty(o,r,{enumerable:!0,get:t[r]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{compositions:()=>t,compositions_metadata:()=>i,overview:()=>r});const t=[],r=[],i={compositions:[]};return o})()));
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/lister",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.110",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/component/lister",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.component",
|
|
8
8
|
"name": "lister",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.110"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"ramda": "0.27.1",
|
|
16
16
|
"@teambit/harmony": "0.4.6",
|
|
17
17
|
"@teambit/component-id": "1.2.0",
|
|
18
|
-
"@teambit/cli": "0.0.
|
|
19
|
-
"@teambit/logger": "0.0.
|
|
20
|
-
"@teambit/workspace": "1.0.
|
|
18
|
+
"@teambit/cli": "0.0.842",
|
|
19
|
+
"@teambit/logger": "0.0.935",
|
|
20
|
+
"@teambit/workspace": "1.0.110"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/cli-table": "^0.3.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/mocha": "9.1.0",
|
|
26
26
|
"@types/jest": "^29.2.2",
|
|
27
27
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
28
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
|
28
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.15"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@teambit/legacy": "1.0.624"
|
|
@@ -34,11 +34,15 @@
|
|
|
34
34
|
"optionalDependencies": {},
|
|
35
35
|
"peerDependenciesMeta": {},
|
|
36
36
|
"exports": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
37
|
+
".": {
|
|
38
|
+
"node": {
|
|
39
|
+
"require": "./dist/index.js",
|
|
40
|
+
"import": "./dist/esm.mjs"
|
|
41
|
+
},
|
|
42
|
+
"default": "./dist/index.js"
|
|
40
43
|
},
|
|
41
|
-
"
|
|
44
|
+
"./dist/*": "./dist/*",
|
|
45
|
+
"./artifacts/*": "./artifacts/*"
|
|
42
46
|
},
|
|
43
47
|
"private": false,
|
|
44
48
|
"engines": {
|
package/index.ts
DELETED
package/list-template.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import c from 'chalk';
|
|
2
|
-
import semver from 'semver';
|
|
3
|
-
import Table from 'cli-table';
|
|
4
|
-
import { ListScopeResult } from './lister.main.runtime';
|
|
5
|
-
|
|
6
|
-
type Row = { id: string; localVersion: string; currentVersion: string; remoteVersion?: string };
|
|
7
|
-
|
|
8
|
-
export function listTemplate(listScopeResults: ListScopeResult[], json: boolean, showRemoteVersion: boolean) {
|
|
9
|
-
function tabulateComponent(listScopeResult: ListScopeResult): Row {
|
|
10
|
-
const id = listScopeResult.id.toStringWithoutVersion();
|
|
11
|
-
let version = listScopeResult.id.hasVersion() ? (listScopeResult.id.version as string) : '<new>';
|
|
12
|
-
if (!json && showRemoteVersion) {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
14
|
-
const color = listScopeResult.remoteVersion && semver.gt(listScopeResult.remoteVersion, version!) ? 'red' : null;
|
|
15
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
16
|
-
version = color ? c[color](version) : version;
|
|
17
|
-
}
|
|
18
|
-
const getFormattedId = () => {
|
|
19
|
-
const { deprecated, laneReadmeOf } = listScopeResult;
|
|
20
|
-
let formattedId = c.white(`${id}`);
|
|
21
|
-
if (deprecated) {
|
|
22
|
-
formattedId = c.white(`${formattedId} [Deprecated]`);
|
|
23
|
-
}
|
|
24
|
-
if (laneReadmeOf && laneReadmeOf.length > 0) {
|
|
25
|
-
formattedId = `${formattedId}\n`;
|
|
26
|
-
laneReadmeOf.forEach((laneName) => {
|
|
27
|
-
formattedId = `${formattedId}${c.yellow(`[Lane Readme]: ${laneName}\n`)}`;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return formattedId;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const data: Row = {
|
|
34
|
-
id: getFormattedId(),
|
|
35
|
-
localVersion: version,
|
|
36
|
-
currentVersion: listScopeResult.currentlyUsedVersion || 'N/A',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
if (showRemoteVersion) {
|
|
40
|
-
let remoteVersion = listScopeResult.remoteVersion || 'N/A';
|
|
41
|
-
const color =
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
|
-
listScopeResult.remoteVersion && semver.gt(listScopeResult.id.version!, listScopeResult.remoteVersion)
|
|
44
|
-
? 'red'
|
|
45
|
-
: null;
|
|
46
|
-
remoteVersion = color ? c[color](remoteVersion) : remoteVersion;
|
|
47
|
-
data.remoteVersion = remoteVersion;
|
|
48
|
-
}
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function toJsonComponent(listScopeResult: ListScopeResult): Record<string, any> {
|
|
53
|
-
const id = listScopeResult.id.toStringWithoutVersion();
|
|
54
|
-
const localVersion = listScopeResult.id.hasVersion() ? (listScopeResult.id.version as string) : '<new>';
|
|
55
|
-
const data = {
|
|
56
|
-
id,
|
|
57
|
-
localVersion,
|
|
58
|
-
deprecated: listScopeResult.deprecated,
|
|
59
|
-
currentVersion: listScopeResult.currentlyUsedVersion || 'N/A',
|
|
60
|
-
remoteVersion: listScopeResult.remoteVersion || 'N/A',
|
|
61
|
-
};
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (json) {
|
|
66
|
-
return listScopeResults.map(toJsonComponent);
|
|
67
|
-
}
|
|
68
|
-
const rows = listScopeResults.map(tabulateComponent);
|
|
69
|
-
const head = ['component ID', 'latest in scope', 'used in workspace'];
|
|
70
|
-
if (showRemoteVersion) {
|
|
71
|
-
head.push('latest in remote scope');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const table = new Table({ head, style: { head: ['cyan'] } });
|
|
75
|
-
rows.map((row) => table.push(Object.values(row)));
|
|
76
|
-
return table.toString();
|
|
77
|
-
}
|
package/list.cmd.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
|
-
import R from 'ramda';
|
|
4
|
-
import hasWildcard from '@teambit/legacy/dist/utils/string/has-wildcard';
|
|
5
|
-
import { listTemplate } from './list-template';
|
|
6
|
-
import { ListerMain, ListScopeResult } from './lister.main.runtime';
|
|
7
|
-
|
|
8
|
-
type ListFlags = {
|
|
9
|
-
ids?: boolean;
|
|
10
|
-
scope?: boolean;
|
|
11
|
-
json?: boolean;
|
|
12
|
-
outdated?: boolean;
|
|
13
|
-
namespace?: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export class ListCmd implements Command {
|
|
17
|
-
name = 'list [remote-scope]';
|
|
18
|
-
description = 'list components on a workspace or a remote scope (with flag).';
|
|
19
|
-
group = 'discover';
|
|
20
|
-
helpUrl = 'reference/reference/cli-reference#list';
|
|
21
|
-
alias = 'ls';
|
|
22
|
-
options = [
|
|
23
|
-
['i', 'ids', 'show only component ids, unformatted'],
|
|
24
|
-
['s', 'scope', 'show only components stored in the local scope, including indirect dependencies'],
|
|
25
|
-
['o', 'outdated', 'highlight outdated components, in comparison with their latest remote version (if one exists)'],
|
|
26
|
-
['j', 'json', 'show the output in JSON format'],
|
|
27
|
-
['n', 'namespace <string>', "show only components in the specified namespace/s e.g. '-n ui' or '*/ui'"],
|
|
28
|
-
] as CommandOptions;
|
|
29
|
-
loader = true;
|
|
30
|
-
migration = true;
|
|
31
|
-
skipWorkspace = true;
|
|
32
|
-
remoteOp = true;
|
|
33
|
-
|
|
34
|
-
constructor(private lister: ListerMain) {}
|
|
35
|
-
|
|
36
|
-
async report([scopeName]: string[], listFlags: ListFlags) {
|
|
37
|
-
const listScopeResults = await this.getListResults(scopeName, listFlags);
|
|
38
|
-
|
|
39
|
-
const { ids, outdated = false } = listFlags;
|
|
40
|
-
|
|
41
|
-
function decideHeaderSentence() {
|
|
42
|
-
if (!scopeName) return `found ${listScopeResults.length} components\n`;
|
|
43
|
-
return chalk.white(`found ${listScopeResults.length} components in ${chalk.bold(scopeName)}\n`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (R.isEmpty(listScopeResults)) {
|
|
47
|
-
return chalk.white(decideHeaderSentence());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (ids) return JSON.stringify(listScopeResults.map((result) => result.id.toString()));
|
|
51
|
-
// TODO - use a cheaper list for ids flag (do not fetch versions at all) @!IMPORTANT
|
|
52
|
-
return decideHeaderSentence() + listTemplate(listScopeResults, false, outdated);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async json([scopeName]: string[], listFlags: ListFlags) {
|
|
56
|
-
const listScopeResults = await this.getListResults(scopeName, listFlags);
|
|
57
|
-
|
|
58
|
-
if (R.isEmpty(listScopeResults)) {
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const { ids, outdated = false } = listFlags;
|
|
63
|
-
if (ids) return listScopeResults.map((result) => result.id.toString());
|
|
64
|
-
return listTemplate(listScopeResults, true, outdated) as Record<string, any>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
private async getListResults(
|
|
68
|
-
scopeName?: string,
|
|
69
|
-
{ namespace, scope, outdated }: ListFlags = {}
|
|
70
|
-
): Promise<ListScopeResult[]> {
|
|
71
|
-
const getNamespaceWithWildcard = () => {
|
|
72
|
-
if (!namespace) return undefined;
|
|
73
|
-
if (hasWildcard(namespace)) return namespace;
|
|
74
|
-
return `${namespace}/*`;
|
|
75
|
-
};
|
|
76
|
-
const namespaceWithWildcard = getNamespaceWithWildcard();
|
|
77
|
-
|
|
78
|
-
return scopeName
|
|
79
|
-
? this.lister.remoteList(scopeName, namespaceWithWildcard)
|
|
80
|
-
: this.lister.localList(scope, outdated, namespaceWithWildcard);
|
|
81
|
-
}
|
|
82
|
-
}
|
package/lister.aspect.ts
DELETED
package/lister.main.runtime.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
|
|
2
|
-
import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
3
|
-
import WorkspaceAspect, { Workspace } from '@teambit/workspace';
|
|
4
|
-
import { BEFORE_LOCAL_LIST, BEFORE_REMOTE_LIST } from '@teambit/legacy/dist/cli/loader/loader-messages';
|
|
5
|
-
import { ComponentID } from '@teambit/component-id';
|
|
6
|
-
import { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';
|
|
7
|
-
import { Remote } from '@teambit/legacy/dist/remotes';
|
|
8
|
-
import getRemoteByName from '@teambit/legacy/dist/remotes/get-remote-by-name';
|
|
9
|
-
import ComponentsList, {
|
|
10
|
-
ListScopeResult as ListScopeResultLegacy,
|
|
11
|
-
} from '@teambit/legacy/dist/consumer/component/components-list';
|
|
12
|
-
import { ListCmd } from './list.cmd';
|
|
13
|
-
import { ListerAspect } from './lister.aspect';
|
|
14
|
-
|
|
15
|
-
export type ListScopeResult = {
|
|
16
|
-
id: ComponentID;
|
|
17
|
-
currentlyUsedVersion?: string | null | undefined;
|
|
18
|
-
remoteVersion?: string;
|
|
19
|
-
deprecated?: boolean;
|
|
20
|
-
laneReadmeOf?: string[];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export class ListerMain {
|
|
24
|
-
constructor(private logger: Logger, private workspace?: Workspace) {}
|
|
25
|
-
|
|
26
|
-
async remoteList(scopeName: string, namespacesUsingWildcards?: string): Promise<ListScopeResult[]> {
|
|
27
|
-
const remote: Remote = await getRemoteByName(scopeName, this.workspace?.consumer);
|
|
28
|
-
this.logger.setStatusLine(BEFORE_REMOTE_LIST);
|
|
29
|
-
const legacyListScopeResult = await remote.list(namespacesUsingWildcards);
|
|
30
|
-
return this.convertListScopeResultsFromLegacy(legacyListScopeResult);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async localList(
|
|
34
|
-
showAll = false,
|
|
35
|
-
showRemoteVersion = false,
|
|
36
|
-
namespacesUsingWildcards?: string
|
|
37
|
-
): Promise<ListScopeResult[]> {
|
|
38
|
-
if (!this.workspace) {
|
|
39
|
-
throw new ConsumerNotFound();
|
|
40
|
-
}
|
|
41
|
-
this.logger.setStatusLine(BEFORE_LOCAL_LIST);
|
|
42
|
-
const componentsList = new ComponentsList(this.workspace.consumer);
|
|
43
|
-
const legacyListScopeResult = await componentsList.listAll(showRemoteVersion, showAll, namespacesUsingWildcards);
|
|
44
|
-
return this.convertListScopeResultsFromLegacy(legacyListScopeResult);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private async convertListScopeResultsFromLegacy(
|
|
48
|
-
legacyListScopeResult: ListScopeResultLegacy[]
|
|
49
|
-
): Promise<ListScopeResult[]> {
|
|
50
|
-
const results = await Promise.all(
|
|
51
|
-
legacyListScopeResult.map(async (legacyResult) => {
|
|
52
|
-
const componentId = legacyResult.id;
|
|
53
|
-
return {
|
|
54
|
-
id: componentId,
|
|
55
|
-
currentlyUsedVersion: legacyResult.currentlyUsedVersion,
|
|
56
|
-
remoteVersion: legacyResult.remoteVersion,
|
|
57
|
-
deprecated: legacyResult.deprecated,
|
|
58
|
-
laneReadmeOf: legacyResult.laneReadmeOf,
|
|
59
|
-
};
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
return results.sort((a, b) => a.id.toString().localeCompare(b.id.toString()));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static slots = [];
|
|
66
|
-
static dependencies = [CLIAspect, LoggerAspect, WorkspaceAspect];
|
|
67
|
-
static runtime = MainRuntime;
|
|
68
|
-
static async provider([cli, loggerMain, workspace]: [CLIMain, LoggerMain, Workspace]) {
|
|
69
|
-
const logger = loggerMain.createLogger(ListerAspect.id);
|
|
70
|
-
const lister = new ListerMain(logger, workspace);
|
|
71
|
-
cli.register(new ListCmd(lister));
|
|
72
|
-
return lister;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
ListerAspect.addRuntime(ListerMain);
|
|
File without changes
|