@teambit/workspace 0.0.773 → 0.0.776

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.
@@ -31,6 +31,16 @@ function _chalk() {
31
31
  return data;
32
32
  }
33
33
 
34
+ function _constants() {
35
+ const data = require("@teambit/legacy/dist/constants");
36
+
37
+ _constants = function () {
38
+ return data;
39
+ };
40
+
41
+ return data;
42
+ }
43
+
34
44
  class EnvsSetCmd {
35
45
  constructor(workspace) {
36
46
  this.workspace = workspace;
@@ -38,7 +48,7 @@ class EnvsSetCmd {
38
48
  (0, _defineProperty2().default)(this, "description", 'Sets one or more components with a development environment (env)');
39
49
  (0, _defineProperty2().default)(this, "arguments", [{
40
50
  name: 'component-pattern',
41
- description: 'component name, component id, or component pattern. use component pattern to select multiple components. \nuse commas to separate patterns and "!" to exclude. e.g. "ui/**, !ui/button"\nwrap the pattern with quotes'
51
+ description: _constants().COMPONENT_PATTERN_HELP
42
52
  }, {
43
53
  name: 'env',
44
54
  description: "the env's component id (include version for non-core envs. e.g, `teambit.community/envs/community-react@1.95.13`)"
@@ -1 +1 @@
1
- {"version":3,"names":["EnvsSetCmd","constructor","workspace","name","description","cmd","report","pattern","env","envId","resolveComponentId","componentIds","idsByPattern","setEnvToComponents","chalk","bold","toString","map","compId","join"],"sources":["envs-set.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class EnvsSetCmd implements Command {\n name = 'set <component-pattern> <env>';\n description = 'Sets one or more components with a development environment (env)';\n arguments = [\n {\n name: 'component-pattern',\n description:\n 'component name, component id, or component pattern. use component pattern to select multiple components. \\nuse commas to separate patterns and \"!\" to exclude. e.g. \"ui/**, !ui/button\"\\nwrap the pattern with quotes',\n },\n {\n name: 'env',\n description:\n \"the env's component id (include version for non-core envs. e.g, `teambit.community/envs/community-react@1.95.13`)\",\n },\n ];\n examples = [\n {\n cmd: 'set ui/button teambit.react/react',\n description: \"configures 'ui/button' to use the 'teambit.react/react' env\",\n },\n {\n cmd: 'set ui/button teambit.community/envs/community-mdx@1.95.16',\n description: \"configures 'ui/button' to use the (non-core) 'teambit.community/envs/community-mdx@1.95.16' env\",\n },\n {\n cmd: 'set \"ui/**\" teambit.react/react',\n description: \"configures all components that have the 'ui' namespace to use the teambit.react/react env\",\n },\n ];\n options = [];\n group = 'development';\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const componentIds = await this.workspace.idsByPattern(pattern);\n await this.workspace.setEnvToComponents(envId, componentIds);\n return `added ${chalk.bold(envId.toString())} env to the following component(s):\n${componentIds.map((compId) => compId.toString()).join('\\n')}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,UAAN,CAAoC;EAgCzCC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CA/BnC,+BA+BmC;IAAA,qDA9B5B,kEA8B4B;IAAA,mDA7B9B,CACV;MACEC,IAAI,EAAE,mBADR;MAEEC,WAAW,EACT;IAHJ,CADU,EAMV;MACED,IAAI,EAAE,KADR;MAEEC,WAAW,EACT;IAHJ,CANU,CA6B8B;IAAA,kDAjB/B,CACT;MACEC,GAAG,EAAE,mCADP;MAEED,WAAW,EAAE;IAFf,CADS,EAKT;MACEC,GAAG,EAAE,4DADP;MAEED,WAAW,EAAE;IAFf,CALS,EAST;MACEC,GAAG,EAAE,iCADP;MAEED,WAAW,EAAE;IAFf,CATS,CAiB+B;IAAA,iDAHhC,EAGgC;IAAA,+CAFlC,aAEkC;EAAE;;EAEhC,MAANE,MAAM,CAAC,CAACC,OAAD,EAAUC,GAAV,CAAD,EAAmC;IAC7C,MAAMC,KAAK,GAAG,MAAM,KAAKP,SAAL,CAAeQ,kBAAf,CAAkCF,GAAlC,CAApB;IACA,MAAMG,YAAY,GAAG,MAAM,KAAKT,SAAL,CAAeU,YAAf,CAA4BL,OAA5B,CAA3B;IACA,MAAM,KAAKL,SAAL,CAAeW,kBAAf,CAAkCJ,KAAlC,EAAyCE,YAAzC,CAAN;IACA,OAAQ,SAAQG,gBAAA,CAAMC,IAAN,CAAWN,KAAK,CAACO,QAAN,EAAX,CAA6B;AACjD,EAAEL,YAAY,CAACM,GAAb,CAAkBC,MAAD,IAAYA,MAAM,CAACF,QAAP,EAA7B,EAAgDG,IAAhD,CAAqD,IAArD,CAA2D,EADzD;EAED;;AAxCwC"}
1
+ {"version":3,"names":["EnvsSetCmd","constructor","workspace","name","description","COMPONENT_PATTERN_HELP","cmd","report","pattern","env","envId","resolveComponentId","componentIds","idsByPattern","setEnvToComponents","chalk","bold","toString","map","compId","join"],"sources":["envs-set.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy/dist/constants';\nimport { Workspace } from '../workspace';\n\nexport class EnvsSetCmd implements Command {\n name = 'set <component-pattern> <env>';\n description = 'Sets one or more components with a development environment (env)';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n {\n name: 'env',\n description:\n \"the env's component id (include version for non-core envs. e.g, `teambit.community/envs/community-react@1.95.13`)\",\n },\n ];\n examples = [\n {\n cmd: 'set ui/button teambit.react/react',\n description: \"configures 'ui/button' to use the 'teambit.react/react' env\",\n },\n {\n cmd: 'set ui/button teambit.community/envs/community-mdx@1.95.16',\n description: \"configures 'ui/button' to use the (non-core) 'teambit.community/envs/community-mdx@1.95.16' env\",\n },\n {\n cmd: 'set \"ui/**\" teambit.react/react',\n description: \"configures all components that have the 'ui' namespace to use the teambit.react/react env\",\n },\n ];\n options = [];\n group = 'development';\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const componentIds = await this.workspace.idsByPattern(pattern);\n await this.workspace.setEnvToComponents(envId, componentIds);\n return `added ${chalk.bold(envId.toString())} env to the following component(s):\n${componentIds.map((compId) => compId.toString()).join('\\n')}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,UAAN,CAAoC;EA+BzCC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CA9BnC,+BA8BmC;IAAA,qDA7B5B,kEA6B4B;IAAA,mDA5B9B,CACV;MACEC,IAAI,EAAE,mBADR;MAEEC,WAAW,EAAEC;IAFf,CADU,EAKV;MACEF,IAAI,EAAE,KADR;MAEEC,WAAW,EACT;IAHJ,CALU,CA4B8B;IAAA,kDAjB/B,CACT;MACEE,GAAG,EAAE,mCADP;MAEEF,WAAW,EAAE;IAFf,CADS,EAKT;MACEE,GAAG,EAAE,4DADP;MAEEF,WAAW,EAAE;IAFf,CALS,EAST;MACEE,GAAG,EAAE,iCADP;MAEEF,WAAW,EAAE;IAFf,CATS,CAiB+B;IAAA,iDAHhC,EAGgC;IAAA,+CAFlC,aAEkC;EAAE;;EAEhC,MAANG,MAAM,CAAC,CAACC,OAAD,EAAUC,GAAV,CAAD,EAAmC;IAC7C,MAAMC,KAAK,GAAG,MAAM,KAAKR,SAAL,CAAeS,kBAAf,CAAkCF,GAAlC,CAApB;IACA,MAAMG,YAAY,GAAG,MAAM,KAAKV,SAAL,CAAeW,YAAf,CAA4BL,OAA5B,CAA3B;IACA,MAAM,KAAKN,SAAL,CAAeY,kBAAf,CAAkCJ,KAAlC,EAAyCE,YAAzC,CAAN;IACA,OAAQ,SAAQG,gBAAA,CAAMC,IAAN,CAAWN,KAAK,CAACO,QAAN,EAAX,CAA6B;AACjD,EAAEL,YAAY,CAACM,GAAb,CAAkBC,MAAD,IAAYA,MAAM,CAACF,QAAP,EAA7B,EAAgDG,IAAhD,CAAqD,IAArD,CAA2D,EADzD;EAED;;AAvCwC"}
@@ -6,6 +6,10 @@ export declare class PatternCommand implements Command {
6
6
  alias: string;
7
7
  description: string;
8
8
  extendedDescription: string;
9
+ examples: {
10
+ cmd: string;
11
+ description: string;
12
+ }[];
9
13
  group: string;
10
14
  private: boolean;
11
15
  options: CommandOptions;
@@ -45,6 +45,22 @@ to exclude, use "!". e.g. "ui/**, !ui/button"
45
45
  always wrap the pattern with quotes to avoid collision with shell commands.
46
46
  the matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)
47
47
  `);
48
+ (0, _defineProperty2().default)(this, "examples", [{
49
+ cmd: 'bit pattern "**"',
50
+ description: 'matches all components'
51
+ }, {
52
+ cmd: 'bit pattern "*/ui/*"',
53
+ description: 'matches components with any scope-name and the "ui" namespace. e.g. "ui/button" but not "ui/elements/button"'
54
+ }, {
55
+ cmd: 'bit pattern "*/ui/**"',
56
+ description: 'matches components that their namespace starts with "ui/" e.g. "ui/button", "ui/elements/button"'
57
+ }, {
58
+ cmd: 'bit pattern "bar, foo"',
59
+ description: 'matches two components: bar and foo'
60
+ }, {
61
+ cmd: 'bit pattern "my-scope.org/**"',
62
+ description: 'matches all components of the scope "my-scope.org"'
63
+ }]);
48
64
  (0, _defineProperty2().default)(this, "group", 'development');
49
65
  (0, _defineProperty2().default)(this, "private", false);
50
66
  (0, _defineProperty2().default)(this, "options", [['j', 'json', 'return the output as JSON']]);
@@ -1 +1 @@
1
- {"version":3,"names":["PatternCommand","constructor","workspace","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n extendedDescription = `this command helps validating a pattern before using it in other commands.\na pattern can be a simple component-id or component-name. e.g. \"ui/button\".\na pattern can be used with wildcards for multiple component ids, e.g. \"org.scope/utils/**\".\nto enter multiple patterns, separate them by a comma, e.g. \"ui/*, lib/*\"\nto exclude, use \"!\". e.g. \"ui/**, !ui/button\"\nalways wrap the pattern with quotes to avoid collision with shell commands.\nthe matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)\n`;\n\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.json([pattern]);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern, false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;EAiB7CC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CAhBnC,mBAgBmC;IAAA,+CAflC,EAekC;IAAA,qDAd5B,mDAc4B;IAAA,6DAbnB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,CAM4C;IAAA,+CAJlC,aAIkC;IAAA,iDAHhC,KAGgC;IAAA,iDAFhC,CAAC,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAAD,CAEgC;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;IAChC,MAAMC,GAAG,GAAG,MAAM,KAAKC,IAAL,CAAU,CAACF,OAAD,CAAV,CAAlB;;IACA,MAAMG,KAAK,GAAGC,gBAAA,CAAMC,KAAN,CAAa,SAAQD,gBAAA,CAAME,IAAN,CAAWL,GAAG,CAACM,MAAJ,CAAWC,QAAX,EAAX,CAAkC,kCAAvD,CAAd;;IACA,OAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAJ,CAAS,IAAT,CAAe,EAAnC;EACD;;EAES,MAAJP,IAAI,CAAC,CAACF,OAAD,CAAD,EAAsB;IAC9B,OAAO,KAAKF,SAAL,CAAeY,YAAf,CAA4BV,OAA5B,EAAqC,KAArC,CAAP;EACD;;AA3B4C"}
1
+ {"version":3,"names":["PatternCommand","constructor","workspace","cmd","description","report","pattern","ids","json","title","chalk","green","bold","length","toString","join","idsByPattern"],"sources":["pattern.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class PatternCommand implements Command {\n name = 'pattern <pattern>';\n alias = '';\n description = 'list the component ids matching the given pattern';\n extendedDescription = `this command helps validating a pattern before using it in other commands.\na pattern can be a simple component-id or component-name. e.g. \"ui/button\".\na pattern can be used with wildcards for multiple component ids, e.g. \"org.scope/utils/**\".\nto enter multiple patterns, separate them by a comma, e.g. \"ui/*, lib/*\"\nto exclude, use \"!\". e.g. \"ui/**, !ui/button\"\nalways wrap the pattern with quotes to avoid collision with shell commands.\nthe matching algorithm is done by multimatch (@see https://github.com/sindresorhus/multimatch)\n`;\n examples = [\n { cmd: 'bit pattern \"**\"', description: 'matches all components' },\n {\n cmd: 'bit pattern \"*/ui/*\"',\n description:\n 'matches components with any scope-name and the \"ui\" namespace. e.g. \"ui/button\" but not \"ui/elements/button\"',\n },\n {\n cmd: 'bit pattern \"*/ui/**\"',\n description: 'matches components that their namespace starts with \"ui/\" e.g. \"ui/button\", \"ui/elements/button\"',\n },\n { cmd: 'bit pattern \"bar, foo\"', description: 'matches two components: bar and foo' },\n { cmd: 'bit pattern \"my-scope.org/**\"', description: 'matches all components of the scope \"my-scope.org\"' },\n ];\n group = 'development';\n private = false;\n options = [['j', 'json', 'return the output as JSON']] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report([pattern]: [string]) {\n const ids = await this.json([pattern]);\n const title = chalk.green(`found ${chalk.bold(ids.length.toString())} components matching the pattern`);\n return `${title}\\n${ids.join('\\n')}`;\n }\n\n async json([pattern]: [string]) {\n return this.workspace.idsByPattern(pattern, false);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,cAAN,CAAwC;EA8B7CC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CA7BnC,mBA6BmC;IAAA,+CA5BlC,EA4BkC;IAAA,qDA3B5B,mDA2B4B;IAAA,6DA1BnB;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,CAmB4C;IAAA,kDAlB/B,CACT;MAAEC,GAAG,EAAE,kBAAP;MAA2BC,WAAW,EAAE;IAAxC,CADS,EAET;MACED,GAAG,EAAE,sBADP;MAEEC,WAAW,EACT;IAHJ,CAFS,EAOT;MACED,GAAG,EAAE,uBADP;MAEEC,WAAW,EAAE;IAFf,CAPS,EAWT;MAAED,GAAG,EAAE,wBAAP;MAAiCC,WAAW,EAAE;IAA9C,CAXS,EAYT;MAAED,GAAG,EAAE,+BAAP;MAAwCC,WAAW,EAAE;IAArD,CAZS,CAkB+B;IAAA,+CAJlC,aAIkC;IAAA,iDAHhC,KAGgC;IAAA,iDAFhC,CAAC,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAAD,CAEgC;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,OAAD,CAAD,EAAsB;IAChC,MAAMC,GAAG,GAAG,MAAM,KAAKC,IAAL,CAAU,CAACF,OAAD,CAAV,CAAlB;;IACA,MAAMG,KAAK,GAAGC,gBAAA,CAAMC,KAAN,CAAa,SAAQD,gBAAA,CAAME,IAAN,CAAWL,GAAG,CAACM,MAAJ,CAAWC,QAAX,EAAX,CAAkC,kCAAvD,CAAd;;IACA,OAAQ,GAAEL,KAAM,KAAIF,GAAG,CAACQ,IAAJ,CAAS,IAAT,CAAe,EAAnC;EACD;;EAES,MAAJP,IAAI,CAAC,CAACF,OAAD,CAAD,EAAsB;IAC9B,OAAO,KAAKJ,SAAL,CAAec,YAAf,CAA4BV,OAA5B,EAAqC,KAArC,CAAP;EACD;;AAxC4C"}
@@ -0,0 +1,19 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { Workspace } from './workspace';
3
+ export declare class UseCmd 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
+ migration: boolean;
16
+ remoteOp: boolean;
17
+ constructor(workspace: Workspace);
18
+ report([id]: [string]): Promise<any>;
19
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ require("core-js/modules/es.array.iterator.js");
6
+
7
+ require("core-js/modules/es.promise.js");
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ exports.UseCmd = void 0;
13
+
14
+ function _defineProperty2() {
15
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+
17
+ _defineProperty2 = function () {
18
+ return data;
19
+ };
20
+
21
+ return data;
22
+ }
23
+
24
+ function _chalk() {
25
+ const data = _interopRequireDefault(require("chalk"));
26
+
27
+ _chalk = function () {
28
+ return data;
29
+ };
30
+
31
+ return data;
32
+ }
33
+
34
+ class UseCmd {
35
+ constructor(workspace) {
36
+ this.workspace = workspace;
37
+ (0, _defineProperty2().default)(this, "name", 'use <component-id>');
38
+ (0, _defineProperty2().default)(this, "group", 'collaborate');
39
+ (0, _defineProperty2().default)(this, "description", 'set aspects in the workspace/scope config to make them loadable by the workspace/scope');
40
+ (0, _defineProperty2().default)(this, "arguments", [{
41
+ name: 'component-id',
42
+ description: 'the component ID of the aspect'
43
+ }]);
44
+ (0, _defineProperty2().default)(this, "alias", '');
45
+ (0, _defineProperty2().default)(this, "options", []);
46
+ (0, _defineProperty2().default)(this, "loader", true);
47
+ (0, _defineProperty2().default)(this, "migration", true);
48
+ (0, _defineProperty2().default)(this, "remoteOp", true);
49
+ }
50
+
51
+ async report([id]) {
52
+ const aspectIdAdded = await this.workspace.use(id);
53
+ return _chalk().default.green(`aspect "${aspectIdAdded}" has been saved into the workspace.jsonc file.`);
54
+ }
55
+
56
+ }
57
+
58
+ exports.UseCmd = UseCmd;
59
+
60
+ //# sourceMappingURL=use.cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UseCmd","constructor","workspace","name","description","report","id","aspectIdAdded","use","chalk","green"],"sources":["use.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from './workspace';\n\nexport class UseCmd implements Command {\n name = 'use <component-id>';\n group = 'collaborate';\n description = 'set aspects in the workspace/scope config to make them loadable by the workspace/scope';\n arguments = [{ name: 'component-id', description: 'the component ID of the aspect' }];\n alias = '';\n options = [] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n\n constructor(private workspace: Workspace) {}\n\n async report([id]: [string]): Promise<any> {\n const aspectIdAdded = await this.workspace.use(id);\n return chalk.green(`aspect \"${aspectIdAdded}\" has been saved into the workspace.jsonc file.`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,MAAN,CAAgC;EAWrCC,WAAW,CAASC,SAAT,EAA+B;IAAA,KAAtBA,SAAsB,GAAtBA,SAAsB;IAAA,8CAVnC,oBAUmC;IAAA,+CATlC,aASkC;IAAA,qDAR5B,wFAQ4B;IAAA,mDAP9B,CAAC;MAAEC,IAAI,EAAE,cAAR;MAAwBC,WAAW,EAAE;IAArC,CAAD,CAO8B;IAAA,+CANlC,EAMkC;IAAA,iDALhC,EAKgC;IAAA,gDAJjC,IAIiC;IAAA,mDAH9B,IAG8B;IAAA,kDAF/B,IAE+B;EAAE;;EAEhC,MAANC,MAAM,CAAC,CAACC,EAAD,CAAD,EAA+B;IACzC,MAAMC,aAAa,GAAG,MAAM,KAAKL,SAAL,CAAeM,GAAf,CAAmBF,EAAnB,CAA5B;IACA,OAAOG,gBAAA,CAAMC,KAAN,CAAa,WAAUH,aAAc,iDAArC,CAAP;EACD;;AAhBoC"}
@@ -310,6 +310,7 @@ export declare class Workspace implements ComponentFactory {
310
310
  * @param forCapsule
311
311
  */
312
312
  importAndGetMany(ids: Array<ComponentID>, forCapsule?: boolean): Promise<Component[]>;
313
+ importCurrentLaneIfMissing(): Promise<void>;
313
314
  /**
314
315
  * @deprecated use this.track() instead
315
316
  * track a new component. (practically, add it to .bitmap).
@@ -320,6 +321,7 @@ export declare class Workspace implements ComponentFactory {
320
321
  * @param override whether add details to an existing component or re-define it
321
322
  */
322
323
  add(componentPaths: PathOsBasedRelative[], id?: string, main?: string, override?: boolean): Promise<AddActionResults>;
324
+ use(aspectIdStr: string): Promise<string>;
323
325
  /**
324
326
  * add a new component to the .bitmap file.
325
327
  * this method only adds the records in memory but doesn't persist to the filesystem.
package/dist/workspace.js CHANGED
@@ -1194,6 +1194,33 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1194
1194
  });
1195
1195
  return this.componentLoader.getMany(ids, forCapsule);
1196
1196
  }
1197
+
1198
+ async importCurrentLaneIfMissing() {
1199
+ const laneId = this.getCurrentLaneId();
1200
+ const laneObj = await this.scope.legacyScope.getCurrentLaneObject();
1201
+
1202
+ if (laneId.isDefault() || laneObj) {
1203
+ return;
1204
+ }
1205
+
1206
+ const lane = await this.getCurrentRemoteLane();
1207
+
1208
+ if (!lane) {
1209
+ return;
1210
+ }
1211
+
1212
+ this.logger.debug(`current lane ${laneId.toString()} is missing, importing it`);
1213
+
1214
+ const scopeComponentsImporter = _scopeComponentsImporter().default.getInstance(this.scope.legacyScope);
1215
+
1216
+ const ids = _bitId().BitIds.fromArray(lane.toBitIds().filter(id => id.hasScope()));
1217
+
1218
+ await scopeComponentsImporter.importManyDeltaWithoutDeps(ids, true, lane);
1219
+ await scopeComponentsImporter.importMany({
1220
+ ids,
1221
+ lanes: lane ? [lane] : undefined
1222
+ });
1223
+ }
1197
1224
  /**
1198
1225
  * @deprecated use this.track() instead
1199
1226
  * track a new component. (practically, add it to .bitmap).
@@ -1220,6 +1247,31 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
1220
1247
  await this.bitMap.write();
1221
1248
  return addResults;
1222
1249
  }
1250
+
1251
+ async use(aspectIdStr) {
1252
+ const aspectId = await this.resolveComponentId(aspectIdStr);
1253
+ let aspectIdToAdd = aspectId.toStringWithoutVersion();
1254
+
1255
+ if (!(await this.hasId(aspectId))) {
1256
+ const loadedIds = await this.scope.loadAspects([aspectIdStr], true);
1257
+ if (loadedIds[0]) aspectIdToAdd = loadedIds[0];
1258
+ }
1259
+
1260
+ const config = this.harmony.get('teambit.harmony/config').workspaceConfig;
1261
+
1262
+ if (!config) {
1263
+ throw new Error(`use() unable to get the workspace config`);
1264
+ }
1265
+
1266
+ config.setExtension(aspectIdToAdd, {}, {
1267
+ overrideExisting: false,
1268
+ ignoreVersion: false
1269
+ });
1270
+ await config.write({
1271
+ dir: _path2().default.dirname(config.path)
1272
+ });
1273
+ return aspectIdToAdd;
1274
+ }
1223
1275
  /**
1224
1276
  * add a new component to the .bitmap file.
1225
1277
  * this method only adds the records in memory but doesn't persist to the filesystem.