forked from teambit/bit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.ts
More file actions
43 lines (38 loc) · 1.71 KB
/
api.ts
File metadata and controls
43 lines (38 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { addMany as addManyInternal, getScopeComponent } from './api/consumer/index';
import { scopeList } from './api/scope/index';
import { AddProps } from './consumer/component-ops/add-components/add-components';
import { Packer } from './pack';
import HooksManager from './hooks';
// import { registerCoreExtensions } from './extensions/bit';
// import { manifestsMap as coreExtensions } from './extensions/bit';
// export { coreExtensions };
HooksManager.init();
export function show(scopePath: string, id: string, opts?: Record<string, any>) {
// When using the API programmatically do not use the scope cache by default
const loadScopeFromCache = opts && opts.loadScopeFromCache !== undefined ? !!opts.loadScopeFromCache : false;
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
return getScopeComponent({ scopePath, id, allVersions: opts && opts.versions, loadScopeFromCache }).then(
({ component }) => {
if (Array.isArray(component)) {
return component.map((v) => v.toObject());
}
return component.toObject();
}
);
}
export function list(
scopePath: string,
namespacesUsingWildcards?: string,
opts: { loadScopeFromCache?: boolean } = {}
) {
// When using the API programmatically do not use the scope cache by default
const loadScopeFromCache = opts && opts.loadScopeFromCache !== undefined ? !!opts.loadScopeFromCache : false;
return scopeList(scopePath, namespacesUsingWildcards, loadScopeFromCache).then((listScopeResult) =>
listScopeResult.map((result) => result.id.toString())
);
}
export async function addMany(components: AddProps[], alternateCwd?: string) {
return addManyInternal(components, alternateCwd);
}
const packer = new Packer();
export { packer };