@teambit/workspace 1.0.346 → 1.0.348

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.
@@ -0,0 +1,85 @@
1
+ /* eslint max-classes-per-file: 0 */
2
+ import chalk from 'chalk';
3
+ import { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';
4
+ import { Command, CommandOptions } from '@teambit/cli';
5
+ import { Workspace } from '../workspace';
6
+
7
+ export class LocalOnlySetCmd implements Command {
8
+ name = 'set <component-pattern>';
9
+ description = 'set a component as local-only';
10
+ arguments = [
11
+ {
12
+ name: 'component-pattern',
13
+ description: COMPONENT_PATTERN_HELP,
14
+ },
15
+ ];
16
+ alias = '';
17
+ options = [] as CommandOptions;
18
+
19
+ constructor(private workspace: Workspace) {}
20
+
21
+ async report([pattern]: [string]) {
22
+ const ids = await this.workspace.idsByPattern(pattern);
23
+ await this.workspace.setLocalOnly(ids);
24
+ const title = chalk.bold(`successfully set the following components as local-only`);
25
+ return `${title}:\n${ids.map((id) => id.toString()).join('\n')}`;
26
+ }
27
+ }
28
+
29
+ export class LocalOnlyUnsetCmd implements Command {
30
+ name = 'unset <component-pattern>';
31
+ description = 'remove a component from local-only';
32
+ arguments = [
33
+ {
34
+ name: 'component-pattern',
35
+ description: COMPONENT_PATTERN_HELP,
36
+ },
37
+ ];
38
+ alias = '';
39
+ options = [] as CommandOptions;
40
+
41
+ constructor(private workspace: Workspace) {}
42
+
43
+ async report([pattern]: [string]) {
44
+ const ids = await this.workspace.idsByPattern(pattern);
45
+ const successfullyUnset = await this.workspace.unsetLocalOnly(ids);
46
+ if (successfullyUnset.length === 0) {
47
+ return chalk.yellow('no local-only components were found');
48
+ }
49
+ const title = chalk.bold(`successfully unset the following component(s)`);
50
+ return `${title}:\n${successfullyUnset.map((id) => id.toString()).join('\n')}`;
51
+ }
52
+ }
53
+
54
+ export class LocalOnlyListCmd implements Command {
55
+ name = 'list';
56
+ description = 'list all local-only components';
57
+ alias = '';
58
+ options = [] as CommandOptions;
59
+
60
+ constructor(private workspace: Workspace) {}
61
+
62
+ async report() {
63
+ const ids = this.workspace.listLocalOnly();
64
+ if (ids.length === 0) {
65
+ return chalk.yellow('no local-only components were found');
66
+ }
67
+ const title = chalk.bold(`the following component(s) are local-only`);
68
+ return `${title}:\n${ids.map((id) => id.toString()).join('\n')}`;
69
+ }
70
+ }
71
+
72
+ export class LocalOnlyCmd implements Command {
73
+ name = 'local-only <sub-command>';
74
+ description = 'manage local-only components, which reside only in the workspace and are not snapped/tagged';
75
+ group = 'development';
76
+ alias = '';
77
+ commands: Command[] = [];
78
+ options = [] as CommandOptions;
79
+
80
+ async report([unrecognizedSubcommand]: [string]) {
81
+ return chalk.red(
82
+ `"${unrecognizedSubcommand}" is not a subcommand of "local-only", please run "bit local-only --help" to list the subcommands`
83
+ );
84
+ }
85
+ }
package/dist/bit-map.d.ts CHANGED
@@ -30,6 +30,9 @@ export declare class BitMap {
30
30
  setEntireConfig(id: ComponentID, config: Record<string, any>): void;
31
31
  removeDefaultScope(id: ComponentID): void;
32
32
  setDefaultScope(id: ComponentID, defaultScope: string): void;
33
+ setLocalOnly(ids: ComponentID[]): void;
34
+ unsetLocalOnly(ids: ComponentID[]): ComponentID[];
35
+ listLocalOnly(): ComponentID[];
33
36
  /**
34
37
  * write .bitmap object to the filesystem
35
38
  * optionally pass a reason for the change to be saved in the local scope `bitmap-history-metadata.txt` file.
package/dist/bit-map.js CHANGED
@@ -165,6 +165,28 @@ class BitMap {
165
165
  bitMapEntry.id = bitMapEntry.id.changeDefaultScope(defaultScope);
166
166
  this.legacyBitMap.markAsChanged();
167
167
  }
168
+ setLocalOnly(ids) {
169
+ ids.forEach(id => {
170
+ const bitMapEntry = this.getBitmapEntry(id);
171
+ bitMapEntry.localOnly = true;
172
+ });
173
+ this.legacyBitMap.markAsChanged();
174
+ }
175
+ unsetLocalOnly(ids) {
176
+ const successfullyUnset = [];
177
+ ids.forEach(id => {
178
+ const bitMapEntry = this.getBitmapEntry(id);
179
+ if (!bitMapEntry.localOnly) return;
180
+ bitMapEntry.localOnly = false;
181
+ successfullyUnset.push(id);
182
+ });
183
+ this.legacyBitMap.markAsChanged();
184
+ return successfullyUnset;
185
+ }
186
+ listLocalOnly() {
187
+ const allIds = this.legacyBitMap.getAllBitIds();
188
+ return allIds.filter(id => this.getBitmapEntry(id).localOnly);
189
+ }
168
190
 
169
191
  /**
170
192
  * write .bitmap object to the filesystem
@@ -1 +1 @@
1
- {"version":3,"names":["_lodash","data","require","_legacy","_config","_bitError","_envs","_toolboxFs","BitMap","constructor","legacyBitMap","consumer","mergeBitmaps","bitmapContent","otherBitmapContent","opts","LegacyBitMap","mergeContent","getPath","mapPath","getAllRootDirs","Object","keys","getAllTrackDirs","addComponentConfig","id","aspectId","config","shouldMergeConfig","Error","bitMapEntry","getBitmapEntry","ignoreVersion","currentConfig","isEqual","getNewConfig","merge","newConfig","markAsChanged","updateDefaultScope","oldScope","newScope","changedId","components","forEach","componentMap","defaultScope","hasVersion","changeDefaultScope","push","length","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","removeEntireConfig","setEntireConfig","removeDefaultScope","setDefaultScope","write","reasonForChange","writeBitMap","getComponent","getBitmapEntryIfExist","getComponentIfExist","getAspectIdFromConfig","componentId","ignoreAspectVersion","undefined","toString","allVersions","filter","startsWith","toStringWithoutVersion","BitError","join","renameNewComponent","sourceId","targetId","fullName","removeComponent","scope","setComponent","renameAspectInConfig","EnvsAspect","envConfig","env","getExportedLaneId","isLaneExported","laneId","makeComponentsAvailableOnMain","ids","isAvailableOnCurrentLane","onLanesOnly","hasChanged","takeSnapshot","map","comp","clone","restoreFromSnapshot","componentMaps","_invalidateCache","getLastModifiedBitmapThroughBit","bitmapHistoryDir","getBitmapHistoryDir","stat","getPathStatIfExist","mtimeMs","exports"],"sources":["bit-map.ts"],"sourcesContent":["import { isEqual, merge } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport { BitMap as LegacyBitMap, ComponentMap, GetBitMapComponentOptions } from '@teambit/legacy.bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\nimport { EnvsAspect } from '@teambit/envs';\nimport { PathOsBasedAbsolute } from '@teambit/toolbox.path.path';\nimport { getPathStatIfExist } from '@teambit/toolbox.fs.last-modified';\n\nexport type MergeOptions = {\n mergeStrategy?: 'theirs' | 'ours' | 'manual';\n};\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n mergeBitmaps(bitmapContent: string, otherBitmapContent: string, opts: MergeOptions = {}): string {\n return LegacyBitMap.mergeContent(bitmapContent, otherBitmapContent, opts);\n }\n\n getPath(): PathOsBasedAbsolute {\n return this.legacyBitMap.mapPath;\n }\n\n getAllRootDirs(): string[] {\n return Object.keys(this.legacyBitMap.getAllTrackDirs());\n }\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(\n id: ComponentID,\n aspectId: string,\n config: Record<string, any> = {},\n shouldMergeConfig = false\n ): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n const getNewConfig = () => {\n if (!config) return null;\n if (!shouldMergeConfig) return config;\n // should merge\n if (!currentConfig) return config;\n if (currentConfig === '-') return config;\n // lodash merge performs a deep merge. (the native concatenation don't)\n return merge(currentConfig, config);\n };\n const newConfig = getNewConfig();\n if (newConfig) {\n bitMapEntry.config[aspectId] = newConfig;\n } else {\n delete bitMapEntry.config[aspectId];\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n updateDefaultScope(oldScope: string, newScope: string) {\n const changedId: ComponentID[] = [];\n this.legacyBitMap.components.forEach((componentMap) => {\n // only new components (not snapped/tagged) can be changed\n if (componentMap.defaultScope === oldScope && !componentMap.id.hasVersion()) {\n componentMap.defaultScope = newScope;\n componentMap.id = componentMap.id.changeDefaultScope(newScope);\n changedId.push(componentMap.id);\n }\n });\n if (changedId.length) {\n this.legacyBitMap.markAsChanged();\n }\n return changedId;\n }\n\n markAsChanged() {\n this.legacyBitMap.markAsChanged();\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeEntireConfig(id: ComponentID): boolean {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n if (!bitMapEntry.config) return false;\n delete bitMapEntry.config;\n this.legacyBitMap.markAsChanged();\n return true;\n }\n\n setEntireConfig(id: ComponentID, config: Record<string, any>) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n bitMapEntry.config = config;\n this.legacyBitMap.markAsChanged();\n }\n\n removeDefaultScope(id: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n if (bitMapEntry.defaultScope) {\n delete bitMapEntry.defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n }\n\n setDefaultScope(id: ComponentID, defaultScope: string) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n bitMapEntry.defaultScope = defaultScope;\n bitMapEntry.id = bitMapEntry.id.changeDefaultScope(defaultScope);\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * write .bitmap object to the filesystem\n * optionally pass a reason for the change to be saved in the local scope `bitmap-history-metadata.txt` file.\n */\n async write(reasonForChange?: string) {\n await this.consumer.writeBitMap(reasonForChange);\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n * throws if not found\n * @see this.getBitmapEntryIfExist\n */\n getBitmapEntry(id: ComponentID, { ignoreVersion }: GetBitMapComponentOptions = {}): ComponentMap {\n return this.legacyBitMap.getComponent(id, { ignoreVersion });\n }\n\n getBitmapEntryIfExist(id: ComponentID, { ignoreVersion }: GetBitMapComponentOptions = {}): ComponentMap | undefined {\n return this.legacyBitMap.getComponentIfExist(id, { ignoreVersion });\n }\n\n getAspectIdFromConfig(\n componentId: ComponentID,\n aspectId: ComponentID,\n ignoreAspectVersion = false\n ): string | undefined {\n const bitMapEntry = this.getBitmapEntry(componentId);\n const config = bitMapEntry.config;\n if (!config) {\n return undefined;\n }\n if (config[aspectId.toString()]) {\n return aspectId.toString();\n }\n if (!ignoreAspectVersion) {\n return undefined;\n }\n const allVersions = Object.keys(config).filter((id) => id.startsWith(`${aspectId.toStringWithoutVersion()}@`));\n if (allVersions.length > 1) {\n throw new BitError(\n `error: the same aspect ${\n aspectId.toStringWithoutVersion\n } configured multiple times for \"${componentId.toString()}\"\\n${allVersions.join('\\n')}`\n );\n }\n return allVersions.length === 1 ? allVersions[0] : undefined;\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n if (sourceId.isEqual(targetId)) {\n throw new Error(`source-id and target-id are equal: \"${sourceId.toString()}\"`);\n }\n if (sourceId.fullName !== targetId.fullName) {\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId;\n if (sourceId.scope !== targetId.scope) bitMapEntry.defaultScope = targetId.scope;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n } else if (sourceId.scope !== targetId.scope) {\n this.setDefaultScope(sourceId, targetId.scope);\n }\n }\n\n /**\n * helpful when reaming an aspect and this aspect is used in the config of other components.\n */\n renameAspectInConfig(sourceId: ComponentID, targetId: ComponentID) {\n this.legacyBitMap.components.forEach((componentMap) => {\n const config = componentMap.config;\n if (!config) return;\n Object.keys(config).forEach((aspectId) => {\n if (aspectId === sourceId.toString()) {\n config[targetId.toString()] = config[aspectId];\n delete config[aspectId];\n this.markAsChanged();\n }\n if (aspectId === EnvsAspect.id) {\n const envConfig = config[aspectId];\n if (envConfig !== '-' && envConfig.env === sourceId.toString()) {\n envConfig.env = targetId.toString();\n this.markAsChanged();\n }\n }\n });\n componentMap.config = config;\n });\n }\n\n removeComponent(id: ComponentID) {\n this.legacyBitMap.removeComponent(id);\n }\n\n /**\n * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be\n * empty.\n */\n getExportedLaneId(): LaneId | undefined {\n return this.legacyBitMap.isLaneExported ? this.legacyBitMap.laneId : undefined;\n }\n\n makeComponentsAvailableOnMain(ids: ComponentID[]) {\n ids.forEach((id) => {\n const componentMap = this.getBitmapEntry(id);\n componentMap.isAvailableOnCurrentLane = true;\n delete componentMap.onLanesOnly;\n });\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * whether .bitmap file has changed in-memory\n */\n hasChanged(): boolean {\n return this.legacyBitMap.hasChanged;\n }\n\n takeSnapshot(): ComponentMap[] {\n return this.legacyBitMap.components.map((comp) => comp.clone());\n }\n\n restoreFromSnapshot(componentMaps: ComponentMap[]) {\n this.legacyBitMap.components = componentMaps;\n this.legacyBitMap._invalidateCache();\n }\n\n /**\n * .bitmap file could be changed by other sources (e.g. manually or by \"git pull\") not only by bit.\n * this method returns the timestamp when the .bitmap has changed through bit. (e.g. as part of snap/tag/export/merge\n * process)\n */\n async getLastModifiedBitmapThroughBit(): Promise<number | undefined> {\n const bitmapHistoryDir = this.consumer.getBitmapHistoryDir();\n const stat = await getPathStatIfExist(bitmapHistoryDir);\n if (!stat) return undefined;\n return stat.mtimeMs;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,WAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,UAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA;AACA;AACA;AACA;AACO,MAAMO,MAAM,CAAC;EAClBC,WAAWA,CAASC,YAA0B,EAAUC,QAAkB,EAAE;IAAA,KAAxDD,YAA0B,GAA1BA,YAA0B;IAAA,KAAUC,QAAkB,GAAlBA,QAAkB;EAAG;EAE7E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;IAC3B,OAAOqC,IAAI,CAACE,OAAO;EACrB;AACF;AAACC,OAAA,CAAAnG,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_lodash","data","require","_legacy","_config","_bitError","_envs","_toolboxFs","BitMap","constructor","legacyBitMap","consumer","mergeBitmaps","bitmapContent","otherBitmapContent","opts","LegacyBitMap","mergeContent","getPath","mapPath","getAllRootDirs","Object","keys","getAllTrackDirs","addComponentConfig","id","aspectId","config","shouldMergeConfig","Error","bitMapEntry","getBitmapEntry","ignoreVersion","currentConfig","isEqual","getNewConfig","merge","newConfig","markAsChanged","updateDefaultScope","oldScope","newScope","changedId","components","forEach","componentMap","defaultScope","hasVersion","changeDefaultScope","push","length","removeComponentConfig","markWithMinusIfNotExist","REMOVE_EXTENSION_SPECIAL_SIGN","removeEntireConfig","setEntireConfig","removeDefaultScope","setDefaultScope","setLocalOnly","ids","localOnly","unsetLocalOnly","successfullyUnset","listLocalOnly","allIds","getAllBitIds","filter","write","reasonForChange","writeBitMap","getComponent","getBitmapEntryIfExist","getComponentIfExist","getAspectIdFromConfig","componentId","ignoreAspectVersion","undefined","toString","allVersions","startsWith","toStringWithoutVersion","BitError","join","renameNewComponent","sourceId","targetId","fullName","removeComponent","scope","setComponent","renameAspectInConfig","EnvsAspect","envConfig","env","getExportedLaneId","isLaneExported","laneId","makeComponentsAvailableOnMain","isAvailableOnCurrentLane","onLanesOnly","hasChanged","takeSnapshot","map","comp","clone","restoreFromSnapshot","componentMaps","_invalidateCache","getLastModifiedBitmapThroughBit","bitmapHistoryDir","getBitmapHistoryDir","stat","getPathStatIfExist","mtimeMs","exports"],"sources":["bit-map.ts"],"sourcesContent":["import { isEqual, merge } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport { BitMap as LegacyBitMap, ComponentMap, GetBitMapComponentOptions } from '@teambit/legacy.bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\nimport { EnvsAspect } from '@teambit/envs';\nimport { PathOsBasedAbsolute } from '@teambit/toolbox.path.path';\nimport { getPathStatIfExist } from '@teambit/toolbox.fs.last-modified';\n\nexport type MergeOptions = {\n mergeStrategy?: 'theirs' | 'ours' | 'manual';\n};\n/**\n * consider extracting to a new component.\n * (pro: making Workspace aspect smaller. con: it's an implementation details of the workspace)\n */\nexport class BitMap {\n constructor(private legacyBitMap: LegacyBitMap, private consumer: Consumer) {}\n\n mergeBitmaps(bitmapContent: string, otherBitmapContent: string, opts: MergeOptions = {}): string {\n return LegacyBitMap.mergeContent(bitmapContent, otherBitmapContent, opts);\n }\n\n getPath(): PathOsBasedAbsolute {\n return this.legacyBitMap.mapPath;\n }\n\n getAllRootDirs(): string[] {\n return Object.keys(this.legacyBitMap.getAllTrackDirs());\n }\n\n /**\n * adds component config to the .bitmap file.\n * later, upon `bit tag`, the data is saved in the scope.\n * returns a boolean indicating whether a change has been made.\n */\n addComponentConfig(\n id: ComponentID,\n aspectId: string,\n config: Record<string, any> = {},\n shouldMergeConfig = false\n ): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n const getNewConfig = () => {\n if (!config) return null;\n if (!shouldMergeConfig) return config;\n // should merge\n if (!currentConfig) return config;\n if (currentConfig === '-') return config;\n // lodash merge performs a deep merge. (the native concatenation don't)\n return merge(currentConfig, config);\n };\n const newConfig = getNewConfig();\n if (newConfig) {\n bitMapEntry.config[aspectId] = newConfig;\n } else {\n delete bitMapEntry.config[aspectId];\n }\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n updateDefaultScope(oldScope: string, newScope: string) {\n const changedId: ComponentID[] = [];\n this.legacyBitMap.components.forEach((componentMap) => {\n // only new components (not snapped/tagged) can be changed\n if (componentMap.defaultScope === oldScope && !componentMap.id.hasVersion()) {\n componentMap.defaultScope = newScope;\n componentMap.id = componentMap.id.changeDefaultScope(newScope);\n changedId.push(componentMap.id);\n }\n });\n if (changedId.length) {\n this.legacyBitMap.markAsChanged();\n }\n return changedId;\n }\n\n markAsChanged() {\n this.legacyBitMap.markAsChanged();\n }\n\n removeComponentConfig(id: ComponentID, aspectId: string, markWithMinusIfNotExist: boolean): boolean {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (currentConfig) {\n delete bitMapEntry.config[aspectId];\n } else {\n if (!markWithMinusIfNotExist) {\n return false; // no changes\n }\n bitMapEntry.config[aspectId] = REMOVE_EXTENSION_SPECIAL_SIGN;\n }\n\n this.legacyBitMap.markAsChanged();\n\n return true; // changes have been made\n }\n\n removeEntireConfig(id: ComponentID): boolean {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n if (!bitMapEntry.config) return false;\n delete bitMapEntry.config;\n this.legacyBitMap.markAsChanged();\n return true;\n }\n\n setEntireConfig(id: ComponentID, config: Record<string, any>) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n bitMapEntry.config = config;\n this.legacyBitMap.markAsChanged();\n }\n\n removeDefaultScope(id: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n if (bitMapEntry.defaultScope) {\n delete bitMapEntry.defaultScope;\n this.legacyBitMap.markAsChanged();\n }\n }\n\n setDefaultScope(id: ComponentID, defaultScope: string) {\n const bitMapEntry = this.getBitmapEntry(id, { ignoreVersion: true });\n bitMapEntry.defaultScope = defaultScope;\n bitMapEntry.id = bitMapEntry.id.changeDefaultScope(defaultScope);\n this.legacyBitMap.markAsChanged();\n }\n\n setLocalOnly(ids: ComponentID[]) {\n ids.forEach((id) => {\n const bitMapEntry = this.getBitmapEntry(id);\n bitMapEntry.localOnly = true;\n });\n this.legacyBitMap.markAsChanged();\n }\n unsetLocalOnly(ids: ComponentID[]): ComponentID[] {\n const successfullyUnset: ComponentID[] = [];\n ids.forEach((id) => {\n const bitMapEntry = this.getBitmapEntry(id);\n if (!bitMapEntry.localOnly) return;\n bitMapEntry.localOnly = false;\n successfullyUnset.push(id);\n });\n this.legacyBitMap.markAsChanged();\n return successfullyUnset;\n }\n listLocalOnly() {\n const allIds = this.legacyBitMap.getAllBitIds();\n return allIds.filter((id) => this.getBitmapEntry(id).localOnly);\n }\n\n /**\n * write .bitmap object to the filesystem\n * optionally pass a reason for the change to be saved in the local scope `bitmap-history-metadata.txt` file.\n */\n async write(reasonForChange?: string) {\n await this.consumer.writeBitMap(reasonForChange);\n }\n\n /**\n * get the data saved in the .bitmap file for this component-id.\n * throws if not found\n * @see this.getBitmapEntryIfExist\n */\n getBitmapEntry(id: ComponentID, { ignoreVersion }: GetBitMapComponentOptions = {}): ComponentMap {\n return this.legacyBitMap.getComponent(id, { ignoreVersion });\n }\n\n getBitmapEntryIfExist(id: ComponentID, { ignoreVersion }: GetBitMapComponentOptions = {}): ComponentMap | undefined {\n return this.legacyBitMap.getComponentIfExist(id, { ignoreVersion });\n }\n\n getAspectIdFromConfig(\n componentId: ComponentID,\n aspectId: ComponentID,\n ignoreAspectVersion = false\n ): string | undefined {\n const bitMapEntry = this.getBitmapEntry(componentId);\n const config = bitMapEntry.config;\n if (!config) {\n return undefined;\n }\n if (config[aspectId.toString()]) {\n return aspectId.toString();\n }\n if (!ignoreAspectVersion) {\n return undefined;\n }\n const allVersions = Object.keys(config).filter((id) => id.startsWith(`${aspectId.toStringWithoutVersion()}@`));\n if (allVersions.length > 1) {\n throw new BitError(\n `error: the same aspect ${\n aspectId.toStringWithoutVersion\n } configured multiple times for \"${componentId.toString()}\"\\n${allVersions.join('\\n')}`\n );\n }\n return allVersions.length === 1 ? allVersions[0] : undefined;\n }\n\n /**\n * components that were not tagged yet are safe to rename them from the .bitmap file.\n */\n renameNewComponent(sourceId: ComponentID, targetId: ComponentID) {\n const bitMapEntry = this.getBitmapEntry(sourceId);\n if (bitMapEntry.id.hasVersion()) {\n throw new Error(`unable to rename tagged or exported component: ${bitMapEntry.id.toString()}`);\n }\n if (sourceId.isEqual(targetId)) {\n throw new Error(`source-id and target-id are equal: \"${sourceId.toString()}\"`);\n }\n if (sourceId.fullName !== targetId.fullName) {\n this.legacyBitMap.removeComponent(bitMapEntry.id);\n bitMapEntry.id = targetId;\n if (sourceId.scope !== targetId.scope) bitMapEntry.defaultScope = targetId.scope;\n this.legacyBitMap.setComponent(bitMapEntry.id, bitMapEntry);\n } else if (sourceId.scope !== targetId.scope) {\n this.setDefaultScope(sourceId, targetId.scope);\n }\n }\n\n /**\n * helpful when reaming an aspect and this aspect is used in the config of other components.\n */\n renameAspectInConfig(sourceId: ComponentID, targetId: ComponentID) {\n this.legacyBitMap.components.forEach((componentMap) => {\n const config = componentMap.config;\n if (!config) return;\n Object.keys(config).forEach((aspectId) => {\n if (aspectId === sourceId.toString()) {\n config[targetId.toString()] = config[aspectId];\n delete config[aspectId];\n this.markAsChanged();\n }\n if (aspectId === EnvsAspect.id) {\n const envConfig = config[aspectId];\n if (envConfig !== '-' && envConfig.env === sourceId.toString()) {\n envConfig.env = targetId.toString();\n this.markAsChanged();\n }\n }\n });\n componentMap.config = config;\n });\n }\n\n removeComponent(id: ComponentID) {\n this.legacyBitMap.removeComponent(id);\n }\n\n /**\n * this is the lane-id of the recently exported lane. in case of a new lane, which was not exported yet, this will be\n * empty.\n */\n getExportedLaneId(): LaneId | undefined {\n return this.legacyBitMap.isLaneExported ? this.legacyBitMap.laneId : undefined;\n }\n\n makeComponentsAvailableOnMain(ids: ComponentID[]) {\n ids.forEach((id) => {\n const componentMap = this.getBitmapEntry(id);\n componentMap.isAvailableOnCurrentLane = true;\n delete componentMap.onLanesOnly;\n });\n this.legacyBitMap.markAsChanged();\n }\n\n /**\n * whether .bitmap file has changed in-memory\n */\n hasChanged(): boolean {\n return this.legacyBitMap.hasChanged;\n }\n\n takeSnapshot(): ComponentMap[] {\n return this.legacyBitMap.components.map((comp) => comp.clone());\n }\n\n restoreFromSnapshot(componentMaps: ComponentMap[]) {\n this.legacyBitMap.components = componentMaps;\n this.legacyBitMap._invalidateCache();\n }\n\n /**\n * .bitmap file could be changed by other sources (e.g. manually or by \"git pull\") not only by bit.\n * this method returns the timestamp when the .bitmap has changed through bit. (e.g. as part of snap/tag/export/merge\n * process)\n */\n async getLastModifiedBitmapThroughBit(): Promise<number | undefined> {\n const bitmapHistoryDir = this.consumer.getBitmapHistoryDir();\n const stat = await getPathStatIfExist(bitmapHistoryDir);\n if (!stat) return undefined;\n return stat.mtimeMs;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,WAAA;EAAA,MAAA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AAA","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { Workspace } from '../workspace';
3
+ export declare class LocalOnlySetCmd implements Command {
4
+ private workspace;
5
+ name: string;
6
+ description: string;
7
+ arguments: {
8
+ name: string;
9
+ description: string;
10
+ }[];
11
+ alias: string;
12
+ options: CommandOptions;
13
+ constructor(workspace: Workspace);
14
+ report([pattern]: [string]): Promise<string>;
15
+ }
16
+ export declare class LocalOnlyUnsetCmd implements Command {
17
+ private workspace;
18
+ name: string;
19
+ description: string;
20
+ arguments: {
21
+ name: string;
22
+ description: string;
23
+ }[];
24
+ alias: string;
25
+ options: CommandOptions;
26
+ constructor(workspace: Workspace);
27
+ report([pattern]: [string]): Promise<string>;
28
+ }
29
+ export declare class LocalOnlyListCmd implements Command {
30
+ private workspace;
31
+ name: string;
32
+ description: string;
33
+ alias: string;
34
+ options: CommandOptions;
35
+ constructor(workspace: Workspace);
36
+ report(): Promise<string>;
37
+ }
38
+ export declare class LocalOnlyCmd implements Command {
39
+ name: string;
40
+ description: string;
41
+ group: string;
42
+ alias: string;
43
+ commands: Command[];
44
+ options: CommandOptions;
45
+ report([unrecognizedSubcommand]: [string]): Promise<string>;
46
+ }
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LocalOnlyUnsetCmd = exports.LocalOnlySetCmd = exports.LocalOnlyListCmd = exports.LocalOnlyCmd = void 0;
7
+ function _chalk() {
8
+ const data = _interopRequireDefault(require("chalk"));
9
+ _chalk = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _constants() {
15
+ const data = require("@teambit/legacy/dist/constants");
16
+ _constants = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
+ 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; }
23
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
24
+ 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); } /* eslint max-classes-per-file: 0 */
25
+ class LocalOnlySetCmd {
26
+ constructor(workspace) {
27
+ this.workspace = workspace;
28
+ _defineProperty(this, "name", 'set <component-pattern>');
29
+ _defineProperty(this, "description", 'set a component as local-only');
30
+ _defineProperty(this, "arguments", [{
31
+ name: 'component-pattern',
32
+ description: _constants().COMPONENT_PATTERN_HELP
33
+ }]);
34
+ _defineProperty(this, "alias", '');
35
+ _defineProperty(this, "options", []);
36
+ }
37
+ async report([pattern]) {
38
+ const ids = await this.workspace.idsByPattern(pattern);
39
+ await this.workspace.setLocalOnly(ids);
40
+ const title = _chalk().default.bold(`successfully set the following components as local-only`);
41
+ return `${title}:\n${ids.map(id => id.toString()).join('\n')}`;
42
+ }
43
+ }
44
+ exports.LocalOnlySetCmd = LocalOnlySetCmd;
45
+ class LocalOnlyUnsetCmd {
46
+ constructor(workspace) {
47
+ this.workspace = workspace;
48
+ _defineProperty(this, "name", 'unset <component-pattern>');
49
+ _defineProperty(this, "description", 'remove a component from local-only');
50
+ _defineProperty(this, "arguments", [{
51
+ name: 'component-pattern',
52
+ description: _constants().COMPONENT_PATTERN_HELP
53
+ }]);
54
+ _defineProperty(this, "alias", '');
55
+ _defineProperty(this, "options", []);
56
+ }
57
+ async report([pattern]) {
58
+ const ids = await this.workspace.idsByPattern(pattern);
59
+ const successfullyUnset = await this.workspace.unsetLocalOnly(ids);
60
+ if (successfullyUnset.length === 0) {
61
+ return _chalk().default.yellow('no local-only components were found');
62
+ }
63
+ const title = _chalk().default.bold(`successfully unset the following component(s)`);
64
+ return `${title}:\n${successfullyUnset.map(id => id.toString()).join('\n')}`;
65
+ }
66
+ }
67
+ exports.LocalOnlyUnsetCmd = LocalOnlyUnsetCmd;
68
+ class LocalOnlyListCmd {
69
+ constructor(workspace) {
70
+ this.workspace = workspace;
71
+ _defineProperty(this, "name", 'list');
72
+ _defineProperty(this, "description", 'list all local-only components');
73
+ _defineProperty(this, "alias", '');
74
+ _defineProperty(this, "options", []);
75
+ }
76
+ async report() {
77
+ const ids = this.workspace.listLocalOnly();
78
+ if (ids.length === 0) {
79
+ return _chalk().default.yellow('no local-only components were found');
80
+ }
81
+ const title = _chalk().default.bold(`the following component(s) are local-only`);
82
+ return `${title}:\n${ids.map(id => id.toString()).join('\n')}`;
83
+ }
84
+ }
85
+ exports.LocalOnlyListCmd = LocalOnlyListCmd;
86
+ class LocalOnlyCmd {
87
+ constructor() {
88
+ _defineProperty(this, "name", 'local-only <sub-command>');
89
+ _defineProperty(this, "description", 'manage local-only components, which reside only in the workspace and are not snapped/tagged');
90
+ _defineProperty(this, "group", 'development');
91
+ _defineProperty(this, "alias", '');
92
+ _defineProperty(this, "commands", []);
93
+ _defineProperty(this, "options", []);
94
+ }
95
+ async report([unrecognizedSubcommand]) {
96
+ return _chalk().default.red(`"${unrecognizedSubcommand}" is not a subcommand of "local-only", please run "bit local-only --help" to list the subcommands`);
97
+ }
98
+ }
99
+ exports.LocalOnlyCmd = LocalOnlyCmd;
100
+
101
+ //# sourceMappingURL=local-only-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_constants","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","LocalOnlySetCmd","constructor","workspace","name","description","COMPONENT_PATTERN_HELP","report","pattern","ids","idsByPattern","setLocalOnly","title","chalk","bold","map","id","toString","join","exports","LocalOnlyUnsetCmd","successfullyUnset","unsetLocalOnly","length","yellow","LocalOnlyListCmd","listLocalOnly","LocalOnlyCmd","unrecognizedSubcommand","red"],"sources":["local-only-cmd.ts"],"sourcesContent":["/* eslint max-classes-per-file: 0 */\nimport chalk from 'chalk';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { Workspace } from '../workspace';\n\nexport class LocalOnlySetCmd implements Command {\n name = 'set <component-pattern>';\n description = 'set a component as local-only';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n alias = '';\n options = [] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.workspace.idsByPattern(pattern);\n await this.workspace.setLocalOnly(ids);\n const title = chalk.bold(`successfully set the following components as local-only`);\n return `${title}:\\n${ids.map((id) => id.toString()).join('\\n')}`;\n }\n}\n\nexport class LocalOnlyUnsetCmd implements Command {\n name = 'unset <component-pattern>';\n description = 'remove a component from local-only';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n alias = '';\n options = [] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.workspace.idsByPattern(pattern);\n const successfullyUnset = await this.workspace.unsetLocalOnly(ids);\n if (successfullyUnset.length === 0) {\n return chalk.yellow('no local-only components were found');\n }\n const title = chalk.bold(`successfully unset the following component(s)`);\n return `${title}:\\n${successfullyUnset.map((id) => id.toString()).join('\\n')}`;\n }\n}\n\nexport class LocalOnlyListCmd implements Command {\n name = 'list';\n description = 'list all local-only components';\n alias = '';\n options = [] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report() {\n const ids = this.workspace.listLocalOnly();\n if (ids.length === 0) {\n return chalk.yellow('no local-only components were found');\n }\n const title = chalk.bold(`the following component(s) are local-only`);\n return `${title}:\\n${ids.map((id) => id.toString()).join('\\n')}`;\n }\n}\n\nexport class LocalOnlyCmd implements Command {\n name = 'local-only <sub-command>';\n description = 'manage local-only components, which reside only in the workspace and are not snapped/tagged';\n group = 'development';\n alias = '';\n commands: Command[] = [];\n options = [] as CommandOptions;\n\n async report([unrecognizedSubcommand]: [string]) {\n return chalk.red(\n `\"${unrecognizedSubcommand}\" is not a subcommand of \"local-only\", please run \"bit local-only --help\" to list the subcommands`\n );\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwE,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAiB,IAAA,CAAAZ,CAAA,EAAAD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MAAME,YAAY,CAAoB;EAAAzB,YAAA;IAAAnB,eAAA,eACpC,0BAA0B;IAAAA,eAAA,sBACnB,6FAA6F;IAAAA,eAAA,gBACnG,aAAa;IAAAA,eAAA,gBACb,EAAE;IAAAA,eAAA,mBACY,EAAE;IAAAA,eAAA,kBACd,EAAE;EAAA;EAEZ,MAAMwB,MAAMA,CAAC,CAACqB,sBAAsB,CAAW,EAAE;IAC/C,OAAOf,gBAAK,CAACgB,GAAG,CACd,IAAID,sBAAsB,mGAC5B,CAAC;EACH;AACF;AAACT,OAAA,CAAAQ,YAAA,GAAAA,YAAA","ignoreList":[]}
package/dist/filter.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ComponentID, ComponentIdList } from '@teambit/component-id';
2
2
  import { Workspace } from './workspace';
3
- export declare const statesFilter: readonly ["new", "modified", "deprecated", "deleted", "snappedOnMain", "softTagged", "codeModified"];
4
- export type StatesFilter = typeof statesFilter[number];
3
+ export declare const statesFilter: readonly ["new", "modified", "deprecated", "deleted", "snappedOnMain", "softTagged", "codeModified", "localOnly"];
4
+ export type StatesFilter = (typeof statesFilter)[number];
5
5
  export declare class Filter {
6
6
  private workspace;
7
7
  constructor(workspace: Workspace);
@@ -11,6 +11,7 @@ export declare class Filter {
11
11
  byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]>;
12
12
  byModified(withinIds?: ComponentID[]): Promise<ComponentID[]>;
13
13
  byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]>;
14
+ byLocalOnly(withinIds?: ComponentID[]): ComponentID[];
14
15
  byNew(withinIds?: ComponentID[]): Promise<ComponentID[]>;
15
16
  byDeprecated(withinIds?: ComponentID[]): Promise<ComponentID[]>;
16
17
  byDeleted(withinIds?: ComponentID[]): Promise<ComponentID[]>;
package/dist/filter.js CHANGED
@@ -26,7 +26,7 @@ function _lodash() {
26
26
  return data;
27
27
  }
28
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
- const statesFilter = exports.statesFilter = ['new', 'modified', 'deprecated', 'deleted', 'snappedOnMain', 'softTagged', 'codeModified'];
29
+ const statesFilter = exports.statesFilter = ['new', 'modified', 'deprecated', 'deleted', 'snappedOnMain', 'softTagged', 'codeModified', 'localOnly'];
30
30
  class Filter {
31
31
  constructor(workspace) {
32
32
  this.workspace = workspace;
@@ -42,7 +42,8 @@ class Filter {
42
42
  deleted: this.byDeleted,
43
43
  snappedOnMain: this.bySnappedOnMain,
44
44
  softTagged: this.bySoftTagged,
45
- codeModified: this.byCodeModified
45
+ codeModified: this.byCodeModified,
46
+ localOnly: this.byLocalOnly
46
47
  };
47
48
  if (!statePerMethod[state]) {
48
49
  throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);
@@ -82,6 +83,12 @@ class Filter {
82
83
  const modifiedIds = compFiles.filter(c => c.isModified()).map(c => c.id);
83
84
  return (0, _lodash().compact)(modifiedIds);
84
85
  }
86
+ byLocalOnly(withinIds) {
87
+ const ids = withinIds || this.workspace.listIds();
88
+ return ids.filter(id => this.workspace.bitMap.getBitmapEntry(id, {
89
+ ignoreVersion: true
90
+ }).localOnly);
91
+ }
85
92
  async byNew(withinIds) {
86
93
  const ids = withinIds || (await this.workspace.listIds());
87
94
  return ids.filter(id => !id.hasVersion());
@@ -1 +1 @@
1
- {"version":3,"names":["_componentId","data","require","_pMapSeries","_interopRequireDefault","_lodash","e","__esModule","default","statesFilter","exports","Filter","constructor","workspace","by","criteria","ids","includes","byMultiParamState","byState","state","statePerMethod","new","byNew","modified","byModified","deprecated","byDeprecated","deleted","byDeleted","snappedOnMain","bySnappedOnMain","softTagged","bySoftTagged","codeModified","byCodeModified","Error","join","bind","stateSplit","split","length","stateName","stateParams","byEnv","env","withinIds","listIds","comps","getMany","compsUsingEnv","filter","c","envId","envs","getEnvId","envIdWithoutVer","ComponentID","getStringWithoutVersion","map","id","modifiedIds","Promise","all","comp","isModified","undefined","compact","compFiles","pMapSeries","getFilesModification","hasVersion","results","modelComponent","consumer","scope","getModelComponentIfExist","isDeprecated","objects","deletedIds","isDeleted","byDuringMergeState","unmergedComponents","legacyScope","getComponents","ComponentIdList","fromArray","u","fromObject","isOnMain","compIds","componentsFromModel","getModelComps","compsDuringMerge","hasWithoutVersion","toComponentId","isHeadSnap","toComponentIdWithHead","withCompIds","bitMap","components","nextVersion","getBitObjectModelComponent"],"sources":["filter.ts"],"sourcesContent":["import { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport pMapSeries from 'p-map-series';\nimport { ModelComponent } from '@teambit/legacy/dist/scope/models';\nimport { compact } from 'lodash';\nimport { Workspace } from './workspace';\n\nexport const statesFilter = [\n 'new',\n 'modified',\n 'deprecated',\n 'deleted',\n 'snappedOnMain',\n 'softTagged',\n 'codeModified',\n] as const;\nexport type StatesFilter = typeof statesFilter[number];\n\nexport class Filter {\n constructor(private workspace: Workspace) {}\n\n async by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]> {\n return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria as StatesFilter, ids);\n }\n\n async byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]> {\n const statePerMethod = {\n new: this.byNew,\n modified: this.byModified,\n deprecated: this.byDeprecated,\n deleted: this.byDeleted,\n snappedOnMain: this.bySnappedOnMain,\n softTagged: this.bySoftTagged,\n codeModified: this.byCodeModified,\n };\n if (!statePerMethod[state]) {\n throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);\n }\n return statePerMethod[state].bind(this)(ids);\n }\n\n async byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]> {\n const stateSplit = state.split(':');\n if (stateSplit.length < 2) {\n throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);\n }\n const [stateName, ...stateParams] = stateSplit;\n if (stateName === 'env') {\n return this.byEnv(stateParams[0], ids);\n }\n throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);\n }\n\n async byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const compsUsingEnv = comps.filter((c) => {\n const envId = this.workspace.envs.getEnvId(c);\n const envIdWithoutVer = ComponentID.getStringWithoutVersion(envId);\n return envIdWithoutVer === env;\n });\n return compsUsingEnv.map((c) => c.id);\n }\n\n async byModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const modifiedIds = await Promise.all(comps.map(async (comp) => ((await comp.isModified()) ? comp.id : undefined)));\n return compact(modifiedIds);\n }\n\n async byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const compFiles = await pMapSeries(ids, (id) => this.workspace.getFilesModification(id));\n const modifiedIds = compFiles.filter((c) => c.isModified()).map((c) => c.id);\n return compact(modifiedIds);\n }\n\n async byNew(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n return ids.filter((id) => !id.hasVersion());\n }\n\n async byDeprecated(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const results = await Promise.all(\n comps.map(async (c) => {\n const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);\n const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);\n return deprecated ? c.id : null;\n })\n );\n return compact(results);\n }\n\n async byDeleted(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const deletedIds = comps.filter((c) => c.isDeleted()).map((c) => c.id);\n return compact(deletedIds);\n }\n\n byDuringMergeState(): ComponentIdList {\n const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();\n return ComponentIdList.fromArray(unmergedComponents.map((u) => ComponentID.fromObject(u.id)));\n }\n\n /**\n * list components that their head is a snap, not a tag.\n * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.\n * components that are during-merge are filtered out, we don't want them during tag and don't want\n * to show them in the \"snapped\" section in bit-status.\n */\n async bySnappedOnMain(withinIds?: ComponentID[]) {\n if (!this.workspace.isOnMain()) {\n return [];\n }\n const ids = withinIds || (await this.workspace.listIds());\n const compIds = ComponentIdList.fromArray(ids);\n const componentsFromModel = await this.getModelComps(ids);\n const compsDuringMerge = this.byDuringMergeState();\n const comps = componentsFromModel\n .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))\n .filter((c) => c.isHeadSnap());\n return comps.map((c) => c.toComponentIdWithHead());\n }\n\n bySoftTagged(withinIds?: ComponentID[]): ComponentID[] {\n const withCompIds = ComponentIdList.fromArray(withinIds || []);\n const all = this.workspace.consumer.bitMap.components.filter((c) => c.nextVersion).map((c) => c.id);\n return withinIds ? all.filter((id) => withCompIds.hasWithoutVersion(id)) : all;\n }\n\n private async getModelComps(ids: ComponentID[]): Promise<ModelComponent[]> {\n const comps = await Promise.all(ids.map((id) => this.workspace.scope.getBitObjectModelComponent(id, false)));\n return compact(comps);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAA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AKsC,WAAW,CAACJ,iBAAiB,CAAClC,EAAE,CAAC,CAAC,GAAGG,GAAG;EAChF;EAEA,MAAc6B,aAAaA,CAAC5E,GAAkB,EAA6B;IACzE,MAAMgC,KAAK,GAAG,MAAMc,OAAO,CAACC,GAAG,CAAC/C,GAAG,CAAC2C,GAAG,CAAEC,EAAE,IAAK,IAAI,CAAC/C,SAAS,CAAC8D,KAAK,CAAC2B,0BAA0B,CAAC1C,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5G,OAAO,IAAAO,iBAAO,EAACnB,KAAK,CAAC;EACvB;AACF;AAACtC,OAAA,CAAAC,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_componentId","data","require","_pMapSeries","_interopRequireDefault","_lodash","e","__esModule","default","statesFilter","exports","Filter","constructor","workspace","by","criteria","ids","includes","byMultiParamState","byState","state","statePerMethod","new","byNew","modified","byModified","deprecated","byDeprecated","deleted","byDeleted","snappedOnMain","bySnappedOnMain","softTagged","bySoftTagged","codeModified","byCodeModified","localOnly","byLocalOnly","Error","join","bind","stateSplit","split","length","stateName","stateParams","byEnv","env","withinIds","listIds","comps","getMany","compsUsingEnv","filter","c","envId","envs","getEnvId","envIdWithoutVer","ComponentID","getStringWithoutVersion","map","id","modifiedIds","Promise","all","comp","isModified","undefined","compact","compFiles","pMapSeries","getFilesModification","bitMap","getBitmapEntry","ignoreVersion","hasVersion","results","modelComponent","consumer","scope","getModelComponentIfExist","isDeprecated","objects","deletedIds","isDeleted","byDuringMergeState","unmergedComponents","legacyScope","getComponents","ComponentIdList","fromArray","u","fromObject","isOnMain","compIds","componentsFromModel","getModelComps","compsDuringMerge","hasWithoutVersion","toComponentId","isHeadSnap","toComponentIdWithHead","withCompIds","components","nextVersion","getBitObjectModelComponent"],"sources":["filter.ts"],"sourcesContent":["import { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport pMapSeries from 'p-map-series';\nimport { ModelComponent } from '@teambit/legacy/dist/scope/models';\nimport { compact } from 'lodash';\nimport { Workspace } from './workspace';\n\nexport const statesFilter = [\n 'new',\n 'modified',\n 'deprecated',\n 'deleted',\n 'snappedOnMain',\n 'softTagged',\n 'codeModified',\n 'localOnly',\n] as const;\nexport type StatesFilter = (typeof statesFilter)[number];\n\nexport class Filter {\n constructor(private workspace: Workspace) {}\n\n async by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]> {\n return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria as StatesFilter, ids);\n }\n\n async byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]> {\n const statePerMethod = {\n new: this.byNew,\n modified: this.byModified,\n deprecated: this.byDeprecated,\n deleted: this.byDeleted,\n snappedOnMain: this.bySnappedOnMain,\n softTagged: this.bySoftTagged,\n codeModified: this.byCodeModified,\n localOnly: this.byLocalOnly,\n };\n if (!statePerMethod[state]) {\n throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);\n }\n return statePerMethod[state].bind(this)(ids);\n }\n\n async byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]> {\n const stateSplit = state.split(':');\n if (stateSplit.length < 2) {\n throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);\n }\n const [stateName, ...stateParams] = stateSplit;\n if (stateName === 'env') {\n return this.byEnv(stateParams[0], ids);\n }\n throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);\n }\n\n async byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const compsUsingEnv = comps.filter((c) => {\n const envId = this.workspace.envs.getEnvId(c);\n const envIdWithoutVer = ComponentID.getStringWithoutVersion(envId);\n return envIdWithoutVer === env;\n });\n return compsUsingEnv.map((c) => c.id);\n }\n\n async byModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const modifiedIds = await Promise.all(comps.map(async (comp) => ((await comp.isModified()) ? comp.id : undefined)));\n return compact(modifiedIds);\n }\n\n async byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const compFiles = await pMapSeries(ids, (id) => this.workspace.getFilesModification(id));\n const modifiedIds = compFiles.filter((c) => c.isModified()).map((c) => c.id);\n return compact(modifiedIds);\n }\n\n byLocalOnly(withinIds?: ComponentID[]): ComponentID[] {\n const ids = withinIds || this.workspace.listIds();\n return ids.filter((id) => this.workspace.bitMap.getBitmapEntry(id, { ignoreVersion: true }).localOnly);\n }\n\n async byNew(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n return ids.filter((id) => !id.hasVersion());\n }\n\n async byDeprecated(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const results = await Promise.all(\n comps.map(async (c) => {\n const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);\n const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);\n return deprecated ? c.id : null;\n })\n );\n return compact(results);\n }\n\n async byDeleted(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const deletedIds = comps.filter((c) => c.isDeleted()).map((c) => c.id);\n return compact(deletedIds);\n }\n\n byDuringMergeState(): ComponentIdList {\n const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();\n return ComponentIdList.fromArray(unmergedComponents.map((u) => ComponentID.fromObject(u.id)));\n }\n\n /**\n * list components that their head is a snap, not a tag.\n * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.\n * components that are during-merge are filtered out, we don't want them during tag and don't want\n * to show them in the \"snapped\" section in bit-status.\n */\n async bySnappedOnMain(withinIds?: ComponentID[]) {\n if (!this.workspace.isOnMain()) {\n return [];\n }\n const ids = withinIds || (await this.workspace.listIds());\n const compIds = ComponentIdList.fromArray(ids);\n const componentsFromModel = await this.getModelComps(ids);\n const compsDuringMerge = this.byDuringMergeState();\n const comps = componentsFromModel\n .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))\n .filter((c) => c.isHeadSnap());\n return comps.map((c) => c.toComponentIdWithHead());\n }\n\n bySoftTagged(withinIds?: ComponentID[]): ComponentID[] {\n const withCompIds = ComponentIdList.fromArray(withinIds || []);\n const all = this.workspace.consumer.bitMap.components.filter((c) => c.nextVersion).map((c) => c.id);\n return withinIds ? all.filter((id) => withCompIds.hasWithoutVersion(id)) : all;\n }\n\n private async getModelComps(ids: ComponentID[]): Promise<ModelComponent[]> {\n const comps = await Promise.all(ids.map((id) => this.workspace.scope.getBitObjectModelComponent(id, false)));\n return compact(comps);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG1B,MAAMG,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAC1B,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,eAAe,EACf,YAAY,EACZ,cAAc,EACd,WAAW,CACH;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AEC,CAAC,IAAKA,CAAC,CAACmD,WAAW,CAAC,CAAC5C,GAAG,CAAEP,CAAC,IAAKA,CAAC,CAACQ,EAAE,CAAC;IACnG,OAAOd,SAAS,GAAGiB,GAAG,CAACZ,MAAM,CAAES,EAAE,IAAKyC,WAAW,CAACJ,iBAAiB,CAACrC,EAAE,CAAC,CAAC,GAAGG,GAAG;EAChF;EAEA,MAAcgC,aAAaA,CAACjF,GAAkB,EAA6B;IACzE,MAAMkC,KAAK,GAAG,MAAMc,OAAO,CAACC,GAAG,CAACjD,GAAG,CAAC6C,GAAG,CAAEC,EAAE,IAAK,IAAI,CAACjD,SAAS,CAACmE,KAAK,CAAC0B,0BAA0B,CAAC5C,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5G,OAAO,IAAAO,iBAAO,EAACnB,KAAK,CAAC;EACvB;AACF;AAACxC,OAAA,CAAAC,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.346/dist/workspace.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.346/dist/workspace.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.348/dist/workspace.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.348/dist/workspace.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/dist/types.d.ts CHANGED
@@ -18,6 +18,11 @@ export interface WorkspaceExtConfig {
18
18
  * set the default directory when there is no matching for the component in the components array.
19
19
  */
20
20
  defaultDirectory: string;
21
+ /**
22
+ * sets the location of the root components directory.
23
+ * The location is a relative path to the workspace root and should use linux path separators (/).
24
+ */
25
+ rootComponentsDirectory?: string;
21
26
  /**
22
27
  * set the default structure of components in your project
23
28
  */
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["interface VendorConfig {\n directory: string;\n}\n\nexport interface WorkspaceExtConfig {\n /**\n * name of the workspace.\n */\n name: string;\n\n /**\n * path to icon.\n */\n icon: string;\n\n /**\n * set the default scope when there is no matching for the component in the components array.\n */\n defaultScope: string;\n\n /**\n * set the default directory when there is no matching for the component in the components array.\n */\n defaultDirectory: string;\n\n /**\n * set the default structure of components in your project\n */\n vendor: VendorConfig;\n\n /**\n * All component extensions applied by default on all components in the workspace (except vendor components)\n */\n extensions: { [extensionsId: string]: string };\n\n /**\n * If set to\n * `true`, it allows the workspace to resolve scope's aspects from node modules\n * installed in the workspace's `node_modules` directory. If not set or set to `false`, aspects will only be resolved\n * from the scope aspects capsule.\n */\n resolveAspectsFromNodeModules?: boolean;\n\n /**\n * If set to `true`, it allows the workspace to resolve envs from node modules\n * installed in the workspace's `node_modules` directory.\n * the envs will be resolved from the node_modules of the env's root (workspace/node_modules/.bit_roots/{envId})\n * and if not found (usually when the env was hoisted to the root node_modules) then from the node_modules of the\n * workspace.\n * If not set or set to `false`, envs will only be resolved from the scope envs capsule.\n */\n resolveEnvsFromRoots?: boolean;\n\n /**\n * If set to `true`, bit will try to load aspects dependencies automatically.\n * even if the aspects dependencies are not configured in the workspace.jsonc root config.\n * for example having the aspect\n * main aspect\n * export class MainAspectMain {\n * ...\n * static dependencies = [MyDepAspect];\n * }\n * and the in the workspace.jsonc file:\n * {\n * ...\n * main-aspect: {}\n * }\n * when set to true, bit will try to load MyDepAspect automatically.\n */\n autoLoadAspectsDeps?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["interface VendorConfig {\n directory: string;\n}\n\nexport interface WorkspaceExtConfig {\n /**\n * name of the workspace.\n */\n name: string;\n\n /**\n * path to icon.\n */\n icon: string;\n\n /**\n * set the default scope when there is no matching for the component in the components array.\n */\n defaultScope: string;\n\n /**\n * set the default directory when there is no matching for the component in the components array.\n */\n defaultDirectory: string;\n\n /**\n * sets the location of the root components directory.\n * The location is a relative path to the workspace root and should use linux path separators (/).\n */\n rootComponentsDirectory?: string;\n\n /**\n * set the default structure of components in your project\n */\n vendor: VendorConfig;\n\n /**\n * All component extensions applied by default on all components in the workspace (except vendor components)\n */\n extensions: { [extensionsId: string]: string };\n\n /**\n * If set to\n * `true`, it allows the workspace to resolve scope's aspects from node modules\n * installed in the workspace's `node_modules` directory. If not set or set to `false`, aspects will only be resolved\n * from the scope aspects capsule.\n */\n resolveAspectsFromNodeModules?: boolean;\n\n /**\n * If set to `true`, it allows the workspace to resolve envs from node modules\n * installed in the workspace's `node_modules` directory.\n * the envs will be resolved from the node_modules of the env's root (workspace/node_modules/.bit_roots/{envId})\n * and if not found (usually when the env was hoisted to the root node_modules) then from the node_modules of the\n * workspace.\n * If not set or set to `false`, envs will only be resolved from the scope envs capsule.\n */\n resolveEnvsFromRoots?: boolean;\n\n /**\n * If set to `true`, bit will try to load aspects dependencies automatically.\n * even if the aspects dependencies are not configured in the workspace.jsonc root config.\n * for example having the aspect\n * main aspect\n * export class MainAspectMain {\n * ...\n * static dependencies = [MyDepAspect];\n * }\n * and the in the workspace.jsonc file:\n * {\n * ...\n * main-aspect: {}\n * }\n * when set to true, bit will try to load MyDepAspect automatically.\n */\n autoLoadAspectsDeps?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -11,6 +11,7 @@ export declare function useWorkspace(options?: UseWorkspaceOptions): {
11
11
  observable: import("@apollo/client").ObservableQuery<any, import("@apollo/client").OperationVariables>;
12
12
  previousData?: any;
13
13
  error?: import("@apollo/client").ApolloError;
14
+ errors?: ReadonlyArray<import("graphql").GraphQLFormattedError>;
14
15
  loading: boolean;
15
16
  networkStatus: import("@apollo/client").NetworkStatus;
16
17
  called: boolean;
@@ -178,6 +178,10 @@ export declare class Workspace implements ComponentFactory {
178
178
  * root path of the Workspace.
179
179
  */
180
180
  get path(): string;
181
+ /**
182
+ * Get the location of the bit roots folder
183
+ */
184
+ get rootComponentsPath(): string;
181
185
  /** get the `node_modules` folder of this workspace */
182
186
  private get modulesPath();
183
187
  get isLegacy(): boolean;
@@ -223,6 +227,7 @@ export declare class Workspace implements ComponentFactory {
223
227
  listInvalid(): Promise<InvalidComponent[]>;
224
228
  /**
225
229
  * get ids of all workspace components.
230
+ * deleted components are filtered out. (use this.listIdsIncludeRemoved() if you need them)
226
231
  */
227
232
  listIds(): ComponentIdList;
228
233
  listIdsIncludeRemoved(): ComponentIdList;
@@ -553,5 +558,8 @@ export declare class Workspace implements ComponentFactory {
553
558
  getAutoDetectConfigMerge(id: ComponentID): import("@teambit/legacy/dist/consumer/config/component-overrides").DependenciesOverridesData | undefined;
554
559
  getManyComponentsStatuses(ids: ComponentID[]): Promise<ComponentStatusResult[]>;
555
560
  getComponentStatusById(id: ComponentID): Promise<ComponentStatusLegacy>;
561
+ setLocalOnly(ids: ComponentID[]): Promise<void>;
562
+ unsetLocalOnly(ids: ComponentID[]): Promise<ComponentID[]>;
563
+ listLocalOnly(): ComponentIdList;
556
564
  }
557
565
  export default Workspace;