@teambit/workspace 0.0.593 → 0.0.597
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/dist/bit-map.d.ts +1 -1
- package/dist/bit-map.js +1 -1
- package/dist/bit-map.js.map +1 -1
- package/dist/install.cmd.d.ts +1 -0
- package/dist/install.cmd.js +4 -3
- package/dist/install.cmd.js.map +1 -1
- package/dist/workspace-component/workspace-component-loader.d.ts +1 -0
- package/dist/workspace-component/workspace-component-loader.js +12 -0
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +6 -0
- package/dist/workspace.js +78 -47
- package/dist/workspace.js.map +1 -1
- package/install.cmd.tsx +4 -1
- package/package-tar/teambit-workspace-0.0.597.tgz +0 -0
- package/package.json +50 -50
- package/workspace-component/workspace-component-loader.ts +11 -0
- package/package-tar/teambit-workspace-0.0.593.tgz +0 -0
package/dist/bit-map.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare class BitMap {
|
|
|
14
14
|
/**
|
|
15
15
|
* adds component config to the .bitmap file.
|
|
16
16
|
* later, upon `bit tag`, the data is saved in the scope.
|
|
17
|
-
* returns a boolean indicating whether a
|
|
17
|
+
* returns a boolean indicating whether a change has been made.
|
|
18
18
|
*/
|
|
19
19
|
addComponentConfig(aspectId: string, id: ComponentID, config?: Record<string, any>): Promise<boolean>;
|
|
20
20
|
/**
|
package/dist/bit-map.js
CHANGED
|
@@ -29,7 +29,7 @@ class BitMap {
|
|
|
29
29
|
/**
|
|
30
30
|
* adds component config to the .bitmap file.
|
|
31
31
|
* later, upon `bit tag`, the data is saved in the scope.
|
|
32
|
-
* returns a boolean indicating whether a
|
|
32
|
+
* returns a boolean indicating whether a change has been made.
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
|
package/dist/bit-map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","aspectId","id","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","write","writeBitMap","ignoreVersion","getComponent","_legacy"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;AACA;AACA;AACA;AACO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW,CAASC,YAAT,EAA6CC,QAA7C,EAAiE;AAAA,SAAxDD,YAAwD,GAAxDA,YAAwD;AAAA,SAApBC,QAAoB,GAApBA,QAAoB;AAAE;AAE9E;AACF;AACA;AACA;AACA;;;AAC0B,QAAlBC,kBAAkB,CAACC,QAAD,EAAmBC,EAAnB,EAAoCC,MAApC,EAAoF;AAC1G,QAAI,CAACF,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIG,KAAJ,CAAW,qCAAoCH,QAAS,EAAxD,CAAN;AAC/C,UAAMI,WAAW,GAAG,KAAKC,cAAL,CAAoBJ,EAApB,EAAwB;AAAEK,MAAAA,qBAAqB,EAAE;AAAzB,KAAxB,CAApB;AACA,UAAMC,aAAa,GAAG,CAACH,WAAW,CAACF,MAAb,KAACE,WAAW,CAACF,MAAb,GAAwB,EAAxB,GAA4BF,QAA5B,CAAtB;;AACA,QAAI,uBAAQO,aAAR,EAAuBL,MAAvB,CAAJ,EAAoC;AAClC,aAAO,KAAP,CADkC,CACpB;AACf;;AACD,QAAI,CAACA,MAAL,EAAa;AACX,aAAOE,WAAW,CAACF,MAAZ,CAAmBF,QAAnB,CAAP;AACD,KAFD,MAEO;AACLI,MAAAA,WAAW,CAACF,MAAZ,CAAmBF,QAAnB,IAA+BE,MAA/B;AACD;;AACD,SAAKL,YAAL,CAAkBW,aAAlB;AACA,UAAM,KAAKC,KAAL,EAAN;AACA,WAAO,IAAP,CAd0G,CAc7F;AACd;AAED;AACF;AACA;;;AACa,QAALA,KAAK,GAAG;AACZ,UAAM,KAAKX,QAAL,CAAcY,WAAd,EAAN;AACD;;AAEDL,EAAAA,cAAc,CACZJ,EADY,EAEZ;AAAEU,IAAAA,aAAF;AAAiBL,IAAAA;AAAjB,MAAsE,EAF1D,EAGE;AACd,WAAO,KAAKT,YAAL,CAAkBe,YAAlB,CAA+BX,EAAE,CAACY,OAAlC,EAA2C;AAAEF,MAAAA,aAAF;AAAiBL,MAAAA;AAAjB,KAA3C,CAAP;AACD;;AArCiB","sourcesContent":["import { isEqual } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\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 /**\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
|
|
1
|
+
{"version":3,"sources":["bit-map.ts"],"names":["BitMap","constructor","legacyBitMap","consumer","addComponentConfig","aspectId","id","config","Error","bitMapEntry","getBitmapEntry","ignoreScopeAndVersion","currentConfig","markAsChanged","write","writeBitMap","ignoreVersion","getComponent","_legacy"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAMA;AACA;AACA;AACA;AACO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW,CAASC,YAAT,EAA6CC,QAA7C,EAAiE;AAAA,SAAxDD,YAAwD,GAAxDA,YAAwD;AAAA,SAApBC,QAAoB,GAApBA,QAAoB;AAAE;AAE9E;AACF;AACA;AACA;AACA;;;AAC0B,QAAlBC,kBAAkB,CAACC,QAAD,EAAmBC,EAAnB,EAAoCC,MAApC,EAAoF;AAC1G,QAAI,CAACF,QAAD,IAAa,OAAOA,QAAP,KAAoB,QAArC,EAA+C,MAAM,IAAIG,KAAJ,CAAW,qCAAoCH,QAAS,EAAxD,CAAN;AAC/C,UAAMI,WAAW,GAAG,KAAKC,cAAL,CAAoBJ,EAApB,EAAwB;AAAEK,MAAAA,qBAAqB,EAAE;AAAzB,KAAxB,CAApB;AACA,UAAMC,aAAa,GAAG,CAACH,WAAW,CAACF,MAAb,KAACE,WAAW,CAACF,MAAb,GAAwB,EAAxB,GAA4BF,QAA5B,CAAtB;;AACA,QAAI,uBAAQO,aAAR,EAAuBL,MAAvB,CAAJ,EAAoC;AAClC,aAAO,KAAP,CADkC,CACpB;AACf;;AACD,QAAI,CAACA,MAAL,EAAa;AACX,aAAOE,WAAW,CAACF,MAAZ,CAAmBF,QAAnB,CAAP;AACD,KAFD,MAEO;AACLI,MAAAA,WAAW,CAACF,MAAZ,CAAmBF,QAAnB,IAA+BE,MAA/B;AACD;;AACD,SAAKL,YAAL,CAAkBW,aAAlB;AACA,UAAM,KAAKC,KAAL,EAAN;AACA,WAAO,IAAP,CAd0G,CAc7F;AACd;AAED;AACF;AACA;;;AACa,QAALA,KAAK,GAAG;AACZ,UAAM,KAAKX,QAAL,CAAcY,WAAd,EAAN;AACD;;AAEDL,EAAAA,cAAc,CACZJ,EADY,EAEZ;AAAEU,IAAAA,aAAF;AAAiBL,IAAAA;AAAjB,MAAsE,EAF1D,EAGE;AACd,WAAO,KAAKT,YAAL,CAAkBe,YAAlB,CAA+BX,EAAE,CAACY,OAAlC,EAA2C;AAAEF,MAAAA,aAAF;AAAiBL,MAAAA;AAAjB,KAA3C,CAAP;AACD;;AArCiB","sourcesContent":["import { isEqual } from 'lodash';\nimport { ComponentID } from '@teambit/component-id';\nimport LegacyBitMap from '@teambit/legacy/dist/consumer/bit-map';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\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 /**\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 async addComponentConfig(aspectId: string, id: ComponentID, config?: Record<string, any>): Promise<boolean> {\n if (!aspectId || typeof aspectId !== 'string') throw new Error(`expect aspectId to be string, got ${aspectId}`);\n const bitMapEntry = this.getBitmapEntry(id, { ignoreScopeAndVersion: true });\n const currentConfig = (bitMapEntry.config ||= {})[aspectId];\n if (isEqual(currentConfig, config)) {\n return false; // no changes\n }\n if (!config) {\n delete bitMapEntry.config[aspectId];\n } else {\n bitMapEntry.config[aspectId] = config;\n }\n this.legacyBitMap.markAsChanged();\n await this.write();\n return true; // changes have been made\n }\n\n /**\n * write .bitmap object to the filesystem\n */\n async write() {\n await this.consumer.writeBitMap();\n }\n\n getBitmapEntry(\n id: ComponentID,\n { ignoreVersion, ignoreScopeAndVersion }: GetBitMapComponentOptions = {}\n ): ComponentMap {\n return this.legacyBitMap.getComponent(id._legacy, { ignoreVersion, ignoreScopeAndVersion });\n }\n}\n"]}
|
package/dist/install.cmd.d.ts
CHANGED
package/dist/install.cmd.js
CHANGED
|
@@ -48,7 +48,7 @@ class InstallCmd {
|
|
|
48
48
|
(0, _defineProperty2().default)(this, "alias", 'in');
|
|
49
49
|
(0, _defineProperty2().default)(this, "group", 'development');
|
|
50
50
|
(0, _defineProperty2().default)(this, "shortDescription", '');
|
|
51
|
-
(0, _defineProperty2().default)(this, "options", [['v', 'variants <variants>', 'add packages to specific variants'], ['t', 'type [lifecycleType]', '"runtime" (default) or "peer" (dev is not a valid option)'], ['u', 'update-existing [updateExisting]', 'update existing dependencies version and types'], ['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'], ['', 'skip-dedupe [skipDedupe]', 'do not dedupe dependencies on installation'], ['', 'skip-import [skipImport]', 'do not import bit objects post installation']]);
|
|
51
|
+
(0, _defineProperty2().default)(this, "options", [['v', 'variants <variants>', 'add packages to specific variants'], ['t', 'type [lifecycleType]', '"runtime" (default) or "peer" (dev is not a valid option)'], ['u', 'update-existing [updateExisting]', 'update existing dependencies version and types'], ['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'], ['', 'skip-dedupe [skipDedupe]', 'do not dedupe dependencies on installation'], ['', 'skip-import [skipImport]', 'do not import bit objects post installation'], ['', 'add-missing-peers [addMissingPeers]', 'install all missing peer dependencies']]);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
async report([packages = []], options) {
|
|
@@ -56,11 +56,12 @@ class InstallCmd {
|
|
|
56
56
|
this.logger.console(`Resolving component dependencies for workspace: '${_chalk().default.cyan(this.workspace.name)}'`);
|
|
57
57
|
const installOpts = {
|
|
58
58
|
variants: options.variants,
|
|
59
|
-
lifecycleType: options.type,
|
|
59
|
+
lifecycleType: options.addMissingPeers ? 'peer' : options.type,
|
|
60
60
|
dedupe: !options.skipDedupe,
|
|
61
61
|
import: !options.skipImport,
|
|
62
62
|
updateExisting: options.updateExisting,
|
|
63
|
-
savePrefix: options.savePrefix
|
|
63
|
+
savePrefix: options.savePrefix,
|
|
64
|
+
addMissingPeers: options.addMissingPeers
|
|
64
65
|
};
|
|
65
66
|
const components = await this.workspace.install(packages, installOpts);
|
|
66
67
|
const endTime = Date.now();
|
package/dist/install.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["install.cmd.tsx"],"names":["InstallCmd","constructor","workspace","logger","report","packages","options","startTime","Date","now","console","chalk","cyan","name","installOpts","variants","lifecycleType","type","dedupe","skipDedupe","import","skipImport","updateExisting","savePrefix","components","install","endTime","executionTime","calculateTime","toArray","length","toString","diff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;
|
|
1
|
+
{"version":3,"sources":["install.cmd.tsx"],"names":["InstallCmd","constructor","workspace","logger","report","packages","options","startTime","Date","now","console","chalk","cyan","name","installOpts","variants","lifecycleType","addMissingPeers","type","dedupe","skipDedupe","import","skipImport","updateExisting","savePrefix","components","install","endTime","executionTime","calculateTime","toArray","length","toString","diff"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAce,MAAMA,UAAN,CAAoC;AAgBjDC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,SAJC;AAMT;AACJ;AACA;AACYC,EAAAA,MATC,EAUT;AAAA,SANQD,SAMR,GANQA,SAMR;AAAA,SADQC,MACR,GADQA,MACR;AAAA,kDAzBK,uBAyBL;AAAA,yDAxBY,4CAwBZ;AAAA,mDAvBM,IAuBN;AAAA,mDAtBM,aAsBN;AAAA,8DArBiB,EAqBjB;AAAA,qDApBQ,CACR,CAAC,GAAD,EAAM,qBAAN,EAA6B,mCAA7B,CADQ,EAER,CAAC,GAAD,EAAM,sBAAN,EAA8B,2DAA9B,CAFQ,EAGR,CAAC,GAAD,EAAM,kCAAN,EAA0C,gDAA1C,CAHQ,EAIR,CAAC,EAAD,EAAK,0BAAL,EAAiC,iEAAjC,CAJQ,EAKR,CAAC,EAAD,EAAK,0BAAL,EAAiC,4CAAjC,CALQ,EAMR,CAAC,EAAD,EAAK,0BAAL,EAAiC,6CAAjC,CANQ,EAOR,CAAC,EAAD,EAAK,qCAAL,EAA4C,uCAA5C,CAPQ,CAoBR;AAAE;;AAEQ,QAANC,MAAM,CAAC,CAACC,QAAQ,GAAG,EAAZ,CAAD,EAA8BC,OAA9B,EAA0D;AACpE,UAAMC,SAAS,GAAGC,IAAI,CAACC,GAAL,EAAlB;AACA,SAAKN,MAAL,CAAYO,OAAZ,CAAqB,oDAAmDC,iBAAMC,IAAN,CAAW,KAAKV,SAAL,CAAeW,IAA1B,CAAgC,GAAxG;AACA,UAAMC,WAAoC,GAAG;AAC3CC,MAAAA,QAAQ,EAAET,OAAO,CAACS,QADyB;AAE3CC,MAAAA,aAAa,EAAEV,OAAO,CAACW,eAAR,GAA0B,MAA1B,GAAmCX,OAAO,CAACY,IAFf;AAG3CC,MAAAA,MAAM,EAAE,CAACb,OAAO,CAACc,UAH0B;AAI3CC,MAAAA,MAAM,EAAE,CAACf,OAAO,CAACgB,UAJ0B;AAK3CC,MAAAA,cAAc,EAAEjB,OAAO,CAACiB,cALmB;AAM3CC,MAAAA,UAAU,EAAElB,OAAO,CAACkB,UANuB;AAO3CP,MAAAA,eAAe,EAAEX,OAAO,CAACW;AAPkB,KAA7C;AASA,UAAMQ,UAAU,GAAG,MAAM,KAAKvB,SAAL,CAAewB,OAAf,CAAuBrB,QAAvB,EAAiCS,WAAjC,CAAzB;AACA,UAAMa,OAAO,GAAGnB,IAAI,CAACC,GAAL,EAAhB;AACA,UAAMmB,aAAa,GAAGC,aAAa,CAACtB,SAAD,EAAYoB,OAAZ,CAAnC;AACA,WAAQ,0CAAyChB,iBAAMC,IAAN,CAC/Ca,UAAU,CAACK,OAAX,GAAqBC,MAArB,CAA4BC,QAA5B,EAD+C,CAE/C,oBAAmBrB,iBAAMC,IAAN,CAAWgB,aAAa,CAACI,QAAd,EAAX,CAAqC,UAF1D;AAGD;;AA9CgD;;;;AAiDnD,SAASH,aAAT,CAAuBtB,SAAvB,EAA0CoB,OAA1C,EAA2D;AACzD,QAAMM,IAAI,GAAGN,OAAO,GAAGpB,SAAvB;AACA,SAAO0B,IAAI,GAAG,IAAd;AACD","sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { WorkspaceDependencyLifecycleType } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport chalk from 'chalk';\n\nimport { Workspace, WorkspaceInstallOptions } from './workspace';\n\ntype InstallCmdOptions = {\n variants: string;\n type: WorkspaceDependencyLifecycleType;\n skipDedupe: boolean;\n skipImport: boolean;\n updateExisting: boolean;\n savePrefix: string;\n addMissingPeers: boolean;\n};\n\nexport default class InstallCmd implements Command {\n name = 'install [packages...]';\n description = 'install development workspace dependencies';\n alias = 'in';\n group = 'development';\n shortDescription = '';\n options = [\n ['v', 'variants <variants>', 'add packages to specific variants'],\n ['t', 'type [lifecycleType]', '\"runtime\" (default) or \"peer\" (dev is not a valid option)'],\n ['u', 'update-existing [updateExisting]', 'update existing dependencies version and types'],\n ['', 'save-prefix [savePrefix]', 'set the prefix to use when adding dependency to workspace.jsonc'],\n ['', 'skip-dedupe [skipDedupe]', 'do not dedupe dependencies on installation'],\n ['', 'skip-import [skipImport]', 'do not import bit objects post installation'],\n ['', 'add-missing-peers [addMissingPeers]', 'install all missing peer dependencies'],\n ] as CommandOptions;\n\n constructor(\n /**\n * workspace extension.\n */\n private workspace: Workspace,\n\n /**\n * logger extension.\n */\n private logger: Logger\n ) {}\n\n async report([packages = []]: [string[]], options: InstallCmdOptions) {\n const startTime = Date.now();\n this.logger.console(`Resolving component dependencies for workspace: '${chalk.cyan(this.workspace.name)}'`);\n const installOpts: WorkspaceInstallOptions = {\n variants: options.variants,\n lifecycleType: options.addMissingPeers ? 'peer' : options.type,\n dedupe: !options.skipDedupe,\n import: !options.skipImport,\n updateExisting: options.updateExisting,\n savePrefix: options.savePrefix,\n addMissingPeers: options.addMissingPeers,\n };\n const components = await this.workspace.install(packages, installOpts);\n const endTime = Date.now();\n const executionTime = calculateTime(startTime, endTime);\n return `Successfully resolved dependencies for ${chalk.cyan(\n components.toArray().length.toString()\n )} component(s) in ${chalk.cyan(executionTime.toString())} seconds`;\n }\n}\n\nfunction calculateTime(startTime: number, endTime: number) {\n const diff = endTime - startTime;\n return diff / 1000;\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export declare class WorkspaceComponentLoader {
|
|
|
15
15
|
getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
|
|
16
16
|
getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]>;
|
|
17
17
|
get(componentId: ComponentID, forCapsule?: boolean, legacyComponent?: ConsumerComponent, useCache?: boolean, storeInCache?: boolean): Promise<Component>;
|
|
18
|
+
getIfExist(componentId: ComponentID): Promise<Component | undefined>;
|
|
18
19
|
private addMultipleEnvsIssueIfNeeded;
|
|
19
20
|
clearCache(): void;
|
|
20
21
|
clearComponentCache(id: ComponentID): void;
|
|
@@ -278,6 +278,18 @@ class WorkspaceComponentLoader {
|
|
|
278
278
|
return component;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
async getIfExist(componentId) {
|
|
282
|
+
try {
|
|
283
|
+
return await this.get(componentId);
|
|
284
|
+
} catch (err) {
|
|
285
|
+
if (this.isComponentNotExistsError(err)) {
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
throw err;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
281
293
|
addMultipleEnvsIssueIfNeeded(component) {
|
|
282
294
|
const envs = this.envs.getAllEnvsConfiguredOnComponent(component);
|
|
283
295
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getAllEnvsConfiguredOnComponent","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","map","e","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensionDataList","componentExtensions","extensionsFromConsumerComponent","extensions","ExtensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,wBAAN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iBAAiB,GAAGvE,SAAS,CAACK,KAAV,CAAgBuD,MAAhB,CAAuBrC,UAAvB,CAAkCiD,aAAlC,CAAgDnB,SAAhD,CAA1B;;AACA,QAAIkB,iBAAJ,EAAuB;AACrB;AACAE,MAAAA,MAAM,CAACC,MAAP,CAAcH,iBAAiB,CAAC7D,IAAhC,EAAsCA,IAAtC;AACA;AACD;;AACDV,IAAAA,SAAS,CAACK,KAAV,CAAgBuD,MAAhB,CAAuBrC,UAAvB,CAAkCtD,IAAlC,CAAuC,MAAM,KAAK0G,YAAL,CAAkBtB,SAAlB,EAA6B3C,IAA7B,CAA7C;AACD;;AAEyB,QAAZiE,YAAY,CAACtB,SAAD,EAAoB3C,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIkE,4BAAJ,EAAuB1G,SAAvB,EAAkCA,SAAlC,EAA6CmF,SAA7C,EAAwDnF,SAAxD,EAAmEwC,IAAnE,CAAP;AACD;;AA9PmC","sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\n }\n return component;\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n if (envs.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envs.map((e) => e.id);\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n\n let extensionDataList = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensionDataList,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","map","e","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensionDataList","componentExtensions","extensionsFromConsumerComponent","extensions","ExtensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA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AAEyB,QAAZiE,YAAY,CAACtB,SAAD,EAAoB3C,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIkE,4BAAJ,EAAuB3G,SAAvB,EAAkCA,SAAlC,EAA6CoF,SAA7C,EAAwDpF,SAAxD,EAAmEyC,IAAnE,CAAP;AACD;;AAzQmC","sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n if (envs.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envs.map((e) => e.id);\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n\n let extensionDataList = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensionDataList,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n"]}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface EjectConfOptions {
|
|
|
45
45
|
override?: boolean;
|
|
46
46
|
}
|
|
47
47
|
export declare type WorkspaceInstallOptions = {
|
|
48
|
+
addMissingPeers?: boolean;
|
|
48
49
|
variants?: string;
|
|
49
50
|
lifecycleType?: WorkspaceDependencyLifecycleType;
|
|
50
51
|
dedupe: boolean;
|
|
@@ -281,6 +282,10 @@ export declare class Workspace implements ComponentFactory {
|
|
|
281
282
|
getComponentsByUserInput(all?: boolean, pattern?: string, includeDependents?: boolean): Promise<Component[]>;
|
|
282
283
|
getMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
|
|
283
284
|
getManyByLegacy(components: ConsumerComponent[]): Promise<Component[]>;
|
|
285
|
+
/**
|
|
286
|
+
* don't throw an error if the component was not found, simply return undefined.
|
|
287
|
+
*/
|
|
288
|
+
getIfExist(componentId: ComponentID): Promise<Component | undefined>;
|
|
284
289
|
/**
|
|
285
290
|
* This will make sure to fetch the objects prior to load them
|
|
286
291
|
* do not use it if you are not sure you need it.
|
|
@@ -399,6 +404,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
399
404
|
* @memberof Workspace
|
|
400
405
|
*/
|
|
401
406
|
install(packages?: string[], options?: WorkspaceInstallOptions): Promise<ComponentMap<string>>;
|
|
407
|
+
private _addPackages;
|
|
402
408
|
private _getComponentsWithDependencyPolicies;
|
|
403
409
|
/**
|
|
404
410
|
* Updates out-of-date dependencies in the workspace.
|
package/dist/workspace.js
CHANGED
|
@@ -109,6 +109,16 @@ function _importer() {
|
|
|
109
109
|
return data;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
function _bitError() {
|
|
113
|
+
const data = require("@teambit/bit-error");
|
|
114
|
+
|
|
115
|
+
_bitError = function () {
|
|
116
|
+
return data;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
|
|
112
122
|
function _dependencyResolver() {
|
|
113
123
|
const data = require("@teambit/dependency-resolver");
|
|
114
124
|
|
|
@@ -289,16 +299,6 @@ function _componentIdToPackageName() {
|
|
|
289
299
|
return data;
|
|
290
300
|
}
|
|
291
301
|
|
|
292
|
-
function _bitError() {
|
|
293
|
-
const data = require("@teambit/bit-error");
|
|
294
|
-
|
|
295
|
-
_bitError = function () {
|
|
296
|
-
return data;
|
|
297
|
-
};
|
|
298
|
-
|
|
299
|
-
return data;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
302
|
function _fsExtra() {
|
|
303
303
|
const data = _interopRequireDefault(require("fs-extra"));
|
|
304
304
|
|
|
@@ -429,6 +429,7 @@ function _bitMap() {
|
|
|
429
429
|
return data;
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
/* eslint-disable max-lines */
|
|
432
433
|
const ComponentAdded = 'componentAdded';
|
|
433
434
|
exports.ComponentAdded = ComponentAdded;
|
|
434
435
|
const ComponentChanged = 'componentChanged';
|
|
@@ -1008,6 +1009,14 @@ class Workspace {
|
|
|
1008
1009
|
return this.get(id, undefined, component);
|
|
1009
1010
|
});
|
|
1010
1011
|
}
|
|
1012
|
+
/**
|
|
1013
|
+
* don't throw an error if the component was not found, simply return undefined.
|
|
1014
|
+
*/
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
async getIfExist(componentId) {
|
|
1018
|
+
return this.componentLoader.getIfExist(componentId);
|
|
1019
|
+
}
|
|
1011
1020
|
/**
|
|
1012
1021
|
* This will make sure to fetch the objects prior to load them
|
|
1013
1022
|
* do not use it if you are not sure you need it.
|
|
@@ -1106,7 +1115,7 @@ class Workspace {
|
|
|
1106
1115
|
|
|
1107
1116
|
async write(rootPath, component) {
|
|
1108
1117
|
await Promise.all(component.filesystem.files.map(async file => {
|
|
1109
|
-
const pathToWrite = _path().default.join(this.path, rootPath, file.
|
|
1118
|
+
const pathToWrite = _path().default.join(this.path, rootPath, file.relative);
|
|
1110
1119
|
|
|
1111
1120
|
await _fsExtra().default.outputFile(pathToWrite, file.contents);
|
|
1112
1121
|
}));
|
|
@@ -1674,40 +1683,25 @@ class Workspace {
|
|
|
1674
1683
|
|
|
1675
1684
|
async install(packages, options) {
|
|
1676
1685
|
if (packages && packages.length) {
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
this.logger.debug(`installing the following packages: ${packages.join()}`);
|
|
1682
|
-
const resolver = await this.dependencyResolver.getVersionResolver();
|
|
1683
|
-
const resolvedPackagesP = packages.map(packageName => resolver.resolveRemoteVersion(packageName, {
|
|
1684
|
-
rootDir: this.path
|
|
1685
|
-
}));
|
|
1686
|
-
const resolvedPackages = await Promise.all(resolvedPackagesP);
|
|
1687
|
-
const newWorkspacePolicyEntries = [];
|
|
1688
|
-
resolvedPackages.forEach(resolvedPackage => {
|
|
1689
|
-
if (resolvedPackage.version) {
|
|
1690
|
-
const versionWithPrefix = this.dependencyResolver.getVersionWithSavePrefix(resolvedPackage.version, options === null || options === void 0 ? void 0 : options.savePrefix);
|
|
1691
|
-
newWorkspacePolicyEntries.push({
|
|
1692
|
-
dependencyId: resolvedPackage.packageName,
|
|
1693
|
-
value: {
|
|
1694
|
-
version: versionWithPrefix
|
|
1695
|
-
},
|
|
1696
|
-
lifecycleType: (options === null || options === void 0 ? void 0 : options.lifecycleType) || 'runtime'
|
|
1697
|
-
});
|
|
1698
|
-
}
|
|
1699
|
-
});
|
|
1700
|
-
|
|
1701
|
-
if (!(options !== null && options !== void 0 && options.variants)) {
|
|
1702
|
-
var _options$updateExisti;
|
|
1703
|
-
|
|
1704
|
-
this.dependencyResolver.addToRootPolicy(newWorkspacePolicyEntries, {
|
|
1705
|
-
updateExisting: (_options$updateExisti = options === null || options === void 0 ? void 0 : options.updateExisting) !== null && _options$updateExisti !== void 0 ? _options$updateExisti : false
|
|
1706
|
-
});
|
|
1707
|
-
} else {// TODO: implement
|
|
1708
|
-
}
|
|
1686
|
+
await this._addPackages(packages, options);
|
|
1687
|
+
}
|
|
1709
1688
|
|
|
1710
|
-
|
|
1689
|
+
if (options !== null && options !== void 0 && options.addMissingPeers) {
|
|
1690
|
+
var _options$copyPeerToRu, _options$copyPeerToRu2;
|
|
1691
|
+
|
|
1692
|
+
const compDirMap = await this.getComponentsDirectory([]);
|
|
1693
|
+
const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
|
|
1694
|
+
const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
|
|
1695
|
+
const pmInstallOptions = {
|
|
1696
|
+
dedupe: options === null || options === void 0 ? void 0 : options.dedupe,
|
|
1697
|
+
copyPeerToRuntimeOnRoot: (_options$copyPeerToRu = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu !== void 0 ? _options$copyPeerToRu : true,
|
|
1698
|
+
copyPeerToRuntimeOnComponents: (_options$copyPeerToRu2 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu2 !== void 0 ? _options$copyPeerToRu2 : false,
|
|
1699
|
+
dependencyFilterFn: depsFilterFn,
|
|
1700
|
+
overrides: this.dependencyResolver.config.overrides
|
|
1701
|
+
};
|
|
1702
|
+
const missingPeers = await this.dependencyResolver.getMissingPeerDependencies(this.path, mergedRootPolicy, compDirMap, pmInstallOptions);
|
|
1703
|
+
const missingPeerPackages = Object.entries(missingPeers).map(([peerName, range]) => `${peerName}@${range}`);
|
|
1704
|
+
await this._addPackages(missingPeerPackages, options);
|
|
1711
1705
|
}
|
|
1712
1706
|
|
|
1713
1707
|
if (options !== null && options !== void 0 && options.import) {
|
|
@@ -1719,6 +1713,43 @@ class Workspace {
|
|
|
1719
1713
|
return this._installModules(options);
|
|
1720
1714
|
}
|
|
1721
1715
|
|
|
1716
|
+
async _addPackages(packages, options) {
|
|
1717
|
+
if (!(options !== null && options !== void 0 && options.variants) && (options === null || options === void 0 ? void 0 : options.lifecycleType) === 'dev') {
|
|
1718
|
+
throw new (_exceptions3().DependencyTypeNotSupportedInPolicy)(options === null || options === void 0 ? void 0 : options.lifecycleType);
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
this.logger.debug(`installing the following packages: ${packages.join()}`);
|
|
1722
|
+
const resolver = await this.dependencyResolver.getVersionResolver();
|
|
1723
|
+
const resolvedPackagesP = packages.map(packageName => resolver.resolveRemoteVersion(packageName, {
|
|
1724
|
+
rootDir: this.path
|
|
1725
|
+
}));
|
|
1726
|
+
const resolvedPackages = await Promise.all(resolvedPackagesP);
|
|
1727
|
+
const newWorkspacePolicyEntries = [];
|
|
1728
|
+
resolvedPackages.forEach(resolvedPackage => {
|
|
1729
|
+
if (resolvedPackage.version) {
|
|
1730
|
+
const versionWithPrefix = this.dependencyResolver.getVersionWithSavePrefix(resolvedPackage.version, options === null || options === void 0 ? void 0 : options.savePrefix);
|
|
1731
|
+
newWorkspacePolicyEntries.push({
|
|
1732
|
+
dependencyId: resolvedPackage.packageName,
|
|
1733
|
+
value: {
|
|
1734
|
+
version: versionWithPrefix
|
|
1735
|
+
},
|
|
1736
|
+
lifecycleType: (options === null || options === void 0 ? void 0 : options.lifecycleType) || 'runtime'
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
|
|
1741
|
+
if (!(options !== null && options !== void 0 && options.variants)) {
|
|
1742
|
+
var _options$updateExisti;
|
|
1743
|
+
|
|
1744
|
+
this.dependencyResolver.addToRootPolicy(newWorkspacePolicyEntries, {
|
|
1745
|
+
updateExisting: (_options$updateExisti = options === null || options === void 0 ? void 0 : options.updateExisting) !== null && _options$updateExisti !== void 0 ? _options$updateExisti : false
|
|
1746
|
+
});
|
|
1747
|
+
} else {// TODO: implement
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
await this.dependencyResolver.persistConfig(this.path);
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1722
1753
|
async _getComponentsWithDependencyPolicies() {
|
|
1723
1754
|
const allComponentIds = await this.listIds();
|
|
1724
1755
|
const componentConfigFiles = {};
|
|
@@ -1821,7 +1852,7 @@ class Workspace {
|
|
|
1821
1852
|
}
|
|
1822
1853
|
|
|
1823
1854
|
async _installModules(options) {
|
|
1824
|
-
var _options$
|
|
1855
|
+
var _options$copyPeerToRu3, _options$copyPeerToRu4;
|
|
1825
1856
|
|
|
1826
1857
|
this.logger.console(`installing dependencies in workspace using ${_chalk().default.cyan(this.dependencyResolver.getPackageManagerName())}`);
|
|
1827
1858
|
this.logger.debug(`installing dependencies in workspace with options`, options);
|
|
@@ -1833,8 +1864,8 @@ class Workspace {
|
|
|
1833
1864
|
const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
|
|
1834
1865
|
const pmInstallOptions = {
|
|
1835
1866
|
dedupe: options === null || options === void 0 ? void 0 : options.dedupe,
|
|
1836
|
-
copyPeerToRuntimeOnRoot: (_options$
|
|
1837
|
-
copyPeerToRuntimeOnComponents: (_options$
|
|
1867
|
+
copyPeerToRuntimeOnRoot: (_options$copyPeerToRu3 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu3 !== void 0 ? _options$copyPeerToRu3 : true,
|
|
1868
|
+
copyPeerToRuntimeOnComponents: (_options$copyPeerToRu4 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu4 !== void 0 ? _options$copyPeerToRu4 : false,
|
|
1838
1869
|
dependencyFilterFn: depsFilterFn,
|
|
1839
1870
|
overrides: this.dependencyResolver.config.overrides
|
|
1840
1871
|
};
|