@teambit/workspace 1.0.259 → 1.0.261
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 +1798 -1440
- package/dist/{preview-1714533890836.js → preview-1714706485042.js} +2 -2
- package/dist/unuse.cmd.d.ts +18 -0
- package/dist/unuse.cmd.js +41 -0
- package/dist/unuse.cmd.js.map +1 -0
- package/dist/workspace.d.ts +5 -2
- package/dist/workspace.js +22 -8
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.main.runtime.js +8 -1
- package/dist/workspace.main.runtime.js.map +1 -1
- package/package.json +20 -20
|
@@ -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.261/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.261/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { Workspace } from './workspace';
|
|
3
|
+
export declare class UnuseCmd implements Command {
|
|
4
|
+
private workspace;
|
|
5
|
+
name: string;
|
|
6
|
+
group: string;
|
|
7
|
+
description: string;
|
|
8
|
+
arguments: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}[];
|
|
12
|
+
alias: string;
|
|
13
|
+
options: CommandOptions;
|
|
14
|
+
loader: boolean;
|
|
15
|
+
remoteOp: boolean;
|
|
16
|
+
constructor(workspace: Workspace);
|
|
17
|
+
report([id]: [string]): Promise<any>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UnuseCmd = void 0;
|
|
7
|
+
function _chalk() {
|
|
8
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
9
|
+
_chalk = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
17
|
+
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); }
|
|
18
|
+
class UnuseCmd {
|
|
19
|
+
constructor(workspace) {
|
|
20
|
+
this.workspace = workspace;
|
|
21
|
+
_defineProperty(this, "name", 'unuse <component-id>');
|
|
22
|
+
_defineProperty(this, "group", 'collaborate');
|
|
23
|
+
_defineProperty(this, "description", 'unset aspects in the workspace config (opposite of "use" command)');
|
|
24
|
+
_defineProperty(this, "arguments", [{
|
|
25
|
+
name: 'component-id',
|
|
26
|
+
description: 'the component ID of the aspect'
|
|
27
|
+
}]);
|
|
28
|
+
_defineProperty(this, "alias", '');
|
|
29
|
+
_defineProperty(this, "options", []);
|
|
30
|
+
_defineProperty(this, "loader", true);
|
|
31
|
+
_defineProperty(this, "remoteOp", true);
|
|
32
|
+
}
|
|
33
|
+
async report([id]) {
|
|
34
|
+
const result = await this.workspace.unuse(id);
|
|
35
|
+
if (!result) return _chalk().default.yellow(`"${id}" was not found in the workspace.jsonc file.`);
|
|
36
|
+
return _chalk().default.green(`workspace.jsonc updated successfully! the aspect "${id}" has been removed.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.UnuseCmd = UnuseCmd;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=unuse.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","UnuseCmd","constructor","workspace","name","description","report","id","result","unuse","chalk","yellow","green","exports"],"sources":["unuse.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class UnuseCmd implements Command {\n name = 'unuse <component-id>';\n group = 'collaborate';\n description = 'unset aspects in the workspace config (opposite of \"use\" command)';\n arguments = [{ name: 'component-id', description: 'the component ID of the aspect' }];\n alias = '';\n options = [] as CommandOptions;\n loader = true;\n remoteOp = true;\n\n constructor(private workspace: Workspace) {}\n\n async report([id]: [string]): Promise<any> {\n const result = await this.workspace.unuse(id);\n if (!result) return chalk.yellow(`\"${id}\" was not found in the workspace.jsonc file.`);\n return chalk.green(`workspace.jsonc updated successfully! the aspect \"${id}\" has been removed.`);\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;AAA0B,SAAAC,uBAAAE,G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AgB;IACzC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACL,SAAS,CAACM,KAAK,CAACF,EAAE,CAAC;IAC7C,IAAI,CAACC,MAAM,EAAE,OAAOE,gBAAK,CAACC,MAAM,CAAE,IAAGJ,EAAG,8CAA6C,CAAC;IACtF,OAAOG,gBAAK,CAACE,KAAK,CAAE,qDAAoDL,EAAG,qBAAoB,CAAC;EAClG;AACF;AAACM,OAAA,CAAAZ,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/dist/workspace.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PubsubMain } from '@teambit/pubsub';
|
|
|
3
3
|
import { IssuesList } from '@teambit/component-issues';
|
|
4
4
|
import type { AspectLoaderMain, AspectDefinition } from '@teambit/aspect-loader';
|
|
5
5
|
import { ComponentMain, Component, ComponentFactory, InvalidComponent, ResolveAspectsOptions } from '@teambit/component';
|
|
6
|
-
import { ComponentScopeDirMap } from '@teambit/config';
|
|
6
|
+
import { ComponentScopeDirMap, WorkspaceConfig } from '@teambit/config';
|
|
7
7
|
import { DependencyResolverMain, DependencyList } from '@teambit/dependency-resolver';
|
|
8
8
|
import { EnvsMain } from '@teambit/envs';
|
|
9
9
|
import { GraphqlMain } from '@teambit/graphql';
|
|
@@ -287,7 +287,8 @@ export declare class Workspace implements ComponentFactory {
|
|
|
287
287
|
clearAllComponentsCache(): void;
|
|
288
288
|
clearComponentCache(id: ComponentID): void;
|
|
289
289
|
warmCache(): Promise<void>;
|
|
290
|
-
|
|
290
|
+
getWorkspaceConfig(): WorkspaceConfig;
|
|
291
|
+
cleanFromConfig(ids: ComponentID[]): Promise<boolean>;
|
|
291
292
|
triggerOnComponentChange(id: ComponentID, files: PathOsBasedAbsolute[], removedFiles: PathOsBasedAbsolute[], watchOpts: WatchOptions): Promise<OnComponentEventResult[]>;
|
|
292
293
|
triggerOnComponentAdd(id: ComponentID, watchOpts: WatchOptions): Promise<OnComponentEventResult[]>;
|
|
293
294
|
triggerOnComponentRemove(id: ComponentID): Promise<OnComponentEventResult[]>;
|
|
@@ -311,6 +312,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
311
312
|
getDefaultExtensions(): ExtensionDataList;
|
|
312
313
|
getComponentConfigVinylFile(id: ComponentID, options: EjectConfOptions, excludeLocalChanges?: boolean): Promise<JsonVinyl>;
|
|
313
314
|
ejectMultipleConfigs(ids: ComponentID[], options: EjectConfOptions): Promise<EjectConfResult[]>;
|
|
315
|
+
getAspectConfigForComponent(id: ComponentID, aspectId: string): Promise<object | undefined>;
|
|
314
316
|
getExtensionsFromScopeAndSpecific(id: ComponentID, excludeComponentJson?: boolean): Promise<ExtensionDataList>;
|
|
315
317
|
/**
|
|
316
318
|
* @deprecated use `this.idsByPattern` instead for consistency. also, it supports negation and list of patterns.
|
|
@@ -362,6 +364,7 @@ export declare class Workspace implements ComponentFactory {
|
|
|
362
364
|
importAndGetMany(ids: Array<ComponentID>, reason?: string, loadOpts?: ComponentLoadOptions, throwOnError?: boolean): Promise<Component[]>;
|
|
363
365
|
importCurrentLaneIfMissing(): Promise<Lane | undefined>;
|
|
364
366
|
use(aspectIdStr: string): Promise<string>;
|
|
367
|
+
unuse(aspectIdStr: string): Promise<boolean>;
|
|
365
368
|
write(component: Component, rootPath?: string): Promise<void>;
|
|
366
369
|
/**
|
|
367
370
|
* @todo: the return path here is Linux when asking for relative and os-based when asking for absolute. fix this to be consistent.
|
package/dist/workspace.js
CHANGED
|
@@ -884,14 +884,20 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
884
884
|
async warmCache() {
|
|
885
885
|
await this.list();
|
|
886
886
|
}
|
|
887
|
-
|
|
887
|
+
getWorkspaceConfig() {
|
|
888
888
|
const config = this.harmony.get('teambit.harmony/config');
|
|
889
889
|
const workspaceConfig = config.workspaceConfig;
|
|
890
890
|
if (!workspaceConfig) throw new Error('workspace config is missing from Config aspect');
|
|
891
|
-
|
|
891
|
+
return workspaceConfig;
|
|
892
|
+
}
|
|
893
|
+
async cleanFromConfig(ids) {
|
|
894
|
+
const workspaceConfig = this.getWorkspaceConfig();
|
|
895
|
+
const wereIdsRemoved = ids.map(id => workspaceConfig.removeExtension(id));
|
|
896
|
+
const hasChanged = wereIdsRemoved.some(isRemoved => isRemoved);
|
|
892
897
|
if (hasChanged) await workspaceConfig.write({
|
|
893
898
|
reasonForChange: 'remove components'
|
|
894
899
|
});
|
|
900
|
+
return hasChanged;
|
|
895
901
|
}
|
|
896
902
|
async triggerOnComponentChange(id, files, removedFiles, watchOpts) {
|
|
897
903
|
const component = await this.get(id);
|
|
@@ -1054,6 +1060,11 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
|
|
|
1054
1060
|
await this.bitMap.write(`eject-conf (${ids.length} component(s))`);
|
|
1055
1061
|
return EjectConfResult;
|
|
1056
1062
|
}
|
|
1063
|
+
async getAspectConfigForComponent(id, aspectId) {
|
|
1064
|
+
const extensions = await this.getExtensionsFromScopeAndSpecific(id);
|
|
1065
|
+
const obj = extensions.toConfigObject();
|
|
1066
|
+
return obj[aspectId];
|
|
1067
|
+
}
|
|
1057
1068
|
async getExtensionsFromScopeAndSpecific(id, excludeComponentJson = false) {
|
|
1058
1069
|
const componentFromScope = await this.scope.get(id);
|
|
1059
1070
|
const exclude = ['WorkspaceVariants'];
|
|
@@ -1238,6 +1249,10 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1238
1249
|
const workspaceAspectsLoader = this.getWorkspaceAspectsLoader();
|
|
1239
1250
|
return workspaceAspectsLoader.use(aspectIdStr);
|
|
1240
1251
|
}
|
|
1252
|
+
async unuse(aspectIdStr) {
|
|
1253
|
+
const compId = await this.resolveComponentId(aspectIdStr);
|
|
1254
|
+
return this.cleanFromConfig([compId]);
|
|
1255
|
+
}
|
|
1241
1256
|
async write(component, rootPath) {
|
|
1242
1257
|
await Promise.all(component.filesystem.files.map(async file => {
|
|
1243
1258
|
const pathToWrite = rootPath ? _path2().default.join(this.path, rootPath, file.relative) : file.path;
|
|
@@ -1478,8 +1493,8 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1478
1493
|
if (!(0, _legacyBitId().isValidScopeName)(scopeName)) {
|
|
1479
1494
|
throw new (_legacyBitId().InvalidScopeName)(scopeName);
|
|
1480
1495
|
}
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1496
|
+
const workspaceConfig = this.getWorkspaceConfig();
|
|
1497
|
+
workspaceConfig.setExtension(_workspace().WorkspaceAspect.id, {
|
|
1483
1498
|
defaultScope: scopeName
|
|
1484
1499
|
}, {
|
|
1485
1500
|
mergeIntoExisting: true,
|
|
@@ -1490,7 +1505,7 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1490
1505
|
this.bitMap.updateDefaultScope(this.config.defaultScope, scopeName);
|
|
1491
1506
|
}
|
|
1492
1507
|
this.config.defaultScope = scopeName;
|
|
1493
|
-
await
|
|
1508
|
+
await workspaceConfig.write({
|
|
1494
1509
|
reasonForChange: `default-scope (${scopeName})`
|
|
1495
1510
|
});
|
|
1496
1511
|
await this.bitMap.write('scope-set');
|
|
@@ -1510,9 +1525,8 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1510
1525
|
});
|
|
1511
1526
|
} else {
|
|
1512
1527
|
if (shouldMergeWithPrevious) {
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1515
|
-
config = obj[aspectId] ? (0, _lodash().merge)(obj[aspectId], config) : config;
|
|
1528
|
+
const existingConfig = await this.getAspectConfigForComponent(id, aspectId);
|
|
1529
|
+
config = existingConfig ? (0, _lodash().merge)(existingConfig, config) : config;
|
|
1516
1530
|
}
|
|
1517
1531
|
this.bitMap.addComponentConfig(id, aspectId, config, shouldMergeWithExisting);
|
|
1518
1532
|
}
|