@teambit/workspace 1.0.444 → 1.0.446
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/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_workspace_workspace-preview.js +1 -1
- package/artifacts/schema.json +1777 -1777
- package/dist/filter.js +2 -1
- package/dist/filter.js.map +1 -1
- package/dist/{preview-1729785193922.js → preview-1729912813344.js} +2 -2
- package/dist/workspace.js +2 -1
- package/dist/workspace.js.map +1 -1
- package/package.json +28 -28
package/dist/filter.js
CHANGED
|
@@ -130,7 +130,8 @@ class Filter {
|
|
|
130
130
|
const compIds = _componentId().ComponentIdList.fromArray(ids);
|
|
131
131
|
const componentsFromModel = await this.getModelComps(ids);
|
|
132
132
|
const compsDuringMerge = this.byDuringMergeState();
|
|
133
|
-
const
|
|
133
|
+
const localOnly = this.workspace.listLocalOnly();
|
|
134
|
+
const comps = componentsFromModel.filter(c => compIds.hasWithoutVersion(c.toComponentId())).filter(c => !compsDuringMerge.hasWithoutVersion(c.toComponentId())).filter(c => !localOnly.hasWithoutVersion(c.toComponentId())).filter(c => c.isHeadSnap());
|
|
134
135
|
return comps.map(c => c.toComponentIdWithHead());
|
|
135
136
|
}
|
|
136
137
|
bySoftTagged(withinIds) {
|
package/dist/filter.js.map
CHANGED
|
@@ -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","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 || 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 if (envId === env) return true;\n // try without version\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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AAM,CAAEC,CAAC,IAAK,CAAC4C,gBAAgB,CAACC,iBAAiB,CAAC7C,CAAC,CAAC8C,aAAa,CAAC,CAAC,CAAC,CAAC,CACrE/C,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAAC+C,UAAU,CAAC,CAAC,CAAC;IAChC,OAAOnD,KAAK,CAACW,GAAG,CAAEP,CAAC,IAAKA,CAAC,CAACgD,qBAAqB,CAAC,CAAC,CAAC;EACpD;EAEArE,YAAYA,CAACe,SAAyB,EAAiB;IACrD,MAAMuD,WAAW,GAAGb,8BAAe,CAACC,SAAS,CAAC3C,SAAS,IAAI,EAAE,CAAC;IAC9D,MAAMiB,GAAG,GAAG,IAAI,CAACpD,SAAS,CAACkE,QAAQ,CAACN,MAAM,CAAC+B,UAAU,CAACnD,MAAM,CAAEC,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
|
+
{"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","listLocalOnly","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 || 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 if (envId === env) return true;\n // try without version\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 localOnly = this.workspace.listLocalOnly();\n const comps = componentsFromModel\n .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !localOnly.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;AAGH,MAAME,MAAM,CAAC;EAClBC,WAAWA,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;EAAG;EAE3C,MAAMC,EAAEA,CAACC,QAA+B,EAAEC,GAAkB,EAA0B;IACpF,OAAOD,QAAQ,CAACE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAACC,iBAAiB,CAACH,QAAQ,EAAEC,GAAG,CAAC,GAAG,IAAI,CAACG,OAAO,CAACJ,QAAQ,EAAkBC,GAAG,CAAC;EACrH;EAEA,MAAMG,OAAOA,CAACC,KAAmB,EAAEJ,GAAkB,EAA0B;IAC7E,MAAMK,cAAc,GAAG;MACrBC,GAAG,EAAE,IAAI,CAACC,KAAK;MACfC,QAAQ,EAAE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EA,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,CAAC2B,0BAA0B,CAAC7C,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.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.446/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.446/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/workspace.js
CHANGED
|
@@ -504,7 +504,8 @@ class Workspace {
|
|
|
504
504
|
const newComponents = await componentsList.listNewComponents();
|
|
505
505
|
if (!modifiedComponents || !modifiedComponents.length) return [];
|
|
506
506
|
const autoTagPending = await this.consumer.listComponentsForAutoTagging(_componentId().ComponentIdList.fromArray(modifiedComponents));
|
|
507
|
-
const
|
|
507
|
+
const localOnly = this.listLocalOnly();
|
|
508
|
+
const comps = autoTagPending.filter(autoTagComp => !newComponents.has(autoTagComp.componentId)).filter(autoTagComp => !localOnly.has(autoTagComp.componentId));
|
|
508
509
|
return comps.map(c => c.id);
|
|
509
510
|
}
|
|
510
511
|
async hasModifiedDependencies(component) {
|