@teambit/tracker 0.0.0-000ec165c902654bff91ecf494e75c45870d03f0

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.
Files changed (72) hide show
  1. package/dist/add-cmd.d.ts +34 -0
  2. package/dist/add-cmd.js +110 -0
  3. package/dist/add-cmd.js.map +1 -0
  4. package/dist/add-components.d.ts +144 -0
  5. package/dist/add-components.js +847 -0
  6. package/dist/add-components.js.map +1 -0
  7. package/dist/determine-main-file.d.ts +4 -0
  8. package/dist/determine-main-file.js +141 -0
  9. package/dist/determine-main-file.js.map +1 -0
  10. package/dist/esm.mjs +12 -0
  11. package/dist/exceptions/adding-individual-files.d.ts +5 -0
  12. package/dist/exceptions/adding-individual-files.js +26 -0
  13. package/dist/exceptions/adding-individual-files.js.map +1 -0
  14. package/dist/exceptions/duplicate-ids.d.ts +5 -0
  15. package/dist/exceptions/duplicate-ids.js +49 -0
  16. package/dist/exceptions/duplicate-ids.js.map +1 -0
  17. package/dist/exceptions/empty-directory.d.ts +4 -0
  18. package/dist/exceptions/empty-directory.js +29 -0
  19. package/dist/exceptions/empty-directory.js.map +1 -0
  20. package/dist/exceptions/excluded-main-file.d.ts +5 -0
  21. package/dist/exceptions/excluded-main-file.js +34 -0
  22. package/dist/exceptions/excluded-main-file.js.map +1 -0
  23. package/dist/exceptions/index.d.ts +10 -0
  24. package/dist/exceptions/index.js +125 -0
  25. package/dist/exceptions/index.js.map +1 -0
  26. package/dist/exceptions/main-file-is-dir.d.ts +5 -0
  27. package/dist/exceptions/main-file-is-dir.js +34 -0
  28. package/dist/exceptions/main-file-is-dir.js.map +1 -0
  29. package/dist/exceptions/missing-main-file-multiple-components.d.ts +5 -0
  30. package/dist/exceptions/missing-main-file-multiple-components.js +41 -0
  31. package/dist/exceptions/missing-main-file-multiple-components.js.map +1 -0
  32. package/dist/exceptions/no-files.d.ts +5 -0
  33. package/dist/exceptions/no-files.js +34 -0
  34. package/dist/exceptions/no-files.js.map +1 -0
  35. package/dist/exceptions/parent-dir-tracked.d.ts +4 -0
  36. package/dist/exceptions/parent-dir-tracked.js +23 -0
  37. package/dist/exceptions/parent-dir-tracked.js.map +1 -0
  38. package/dist/exceptions/path-outside-consumer.d.ts +5 -0
  39. package/dist/exceptions/path-outside-consumer.js +34 -0
  40. package/dist/exceptions/path-outside-consumer.js.map +1 -0
  41. package/dist/exceptions/paths-not-exist.d.ts +6 -0
  42. package/dist/exceptions/paths-not-exist.js +36 -0
  43. package/dist/exceptions/paths-not-exist.js.map +1 -0
  44. package/dist/exceptions/version-should-be-removed.d.ts +5 -0
  45. package/dist/exceptions/version-should-be-removed.js +34 -0
  46. package/dist/exceptions/version-should-be-removed.js.map +1 -0
  47. package/dist/index.d.ts +7 -0
  48. package/dist/index.js +73 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/preview-1758833689744.js +7 -0
  51. package/dist/tracker.aspect.d.ts +2 -0
  52. package/dist/tracker.aspect.js +18 -0
  53. package/dist/tracker.aspect.js.map +1 -0
  54. package/dist/tracker.main.runtime.d.ts +71 -0
  55. package/dist/tracker.main.runtime.js +186 -0
  56. package/dist/tracker.main.runtime.js.map +1 -0
  57. package/esm.mjs +12 -0
  58. package/exceptions/adding-individual-files.ts +9 -0
  59. package/exceptions/duplicate-ids.ts +25 -0
  60. package/exceptions/empty-directory.ts +8 -0
  61. package/exceptions/excluded-main-file.ts +10 -0
  62. package/exceptions/index.ts +21 -0
  63. package/exceptions/main-file-is-dir.ts +12 -0
  64. package/exceptions/missing-main-file-multiple-components.ts +16 -0
  65. package/exceptions/no-files.ts +14 -0
  66. package/exceptions/parent-dir-tracked.ts +9 -0
  67. package/exceptions/path-outside-consumer.ts +10 -0
  68. package/exceptions/paths-not-exist.ts +13 -0
  69. package/exceptions/version-should-be-removed.ts +10 -0
  70. package/package.json +73 -0
  71. package/types/asset.d.ts +41 -0
  72. package/types/style.d.ts +42 -0
@@ -0,0 +1,34 @@
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { PathLinux } from '@teambit/legacy.utils';
3
+ import type { Warnings } from './add-components';
4
+ import type { TrackerMain } from './tracker.main.runtime';
5
+ type AddFlags = {
6
+ id: string | null | undefined;
7
+ main: string | null | undefined;
8
+ namespace: string | null | undefined;
9
+ scope?: string;
10
+ env?: string;
11
+ override: boolean;
12
+ };
13
+ type AddResults = {
14
+ addedComponents: Array<{
15
+ id: string;
16
+ files: PathLinux[];
17
+ }>;
18
+ warnings: Warnings;
19
+ };
20
+ export declare class AddCmd implements Command {
21
+ private tracker;
22
+ name: string;
23
+ description: string;
24
+ group: string;
25
+ extendedDescription: string;
26
+ helpUrl: string;
27
+ alias: string;
28
+ options: CommandOptions;
29
+ loader: boolean;
30
+ constructor(tracker: TrackerMain);
31
+ report([paths]: [string[]], addFlags: AddFlags): Promise<string>;
32
+ json([paths]: [string[]], { id, main, namespace, scope, env, override }: AddFlags): Promise<AddResults>;
33
+ }
34
+ export {};
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AddCmd = void 0;
7
+ function _chalk() {
8
+ const data = _interopRequireDefault(require("chalk"));
9
+ _chalk = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function path() {
15
+ const data = _interopRequireWildcard(require("path"));
16
+ path = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _bitError() {
22
+ const data = require("@teambit/bit-error");
23
+ _bitError = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
29
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
30
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
31
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
32
+ 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); }
33
+ class AddCmd {
34
+ constructor(tracker) {
35
+ this.tracker = tracker;
36
+ _defineProperty(this, "name", 'add [path...]');
37
+ _defineProperty(this, "description", 'track existing directory contents as new components in the workspace');
38
+ _defineProperty(this, "group", 'component-development');
39
+ _defineProperty(this, "extendedDescription", 'Registers one or more directories as Bit components without changing your files. Each provided path becomes a component root tracked by Bit.');
40
+ _defineProperty(this, "helpUrl", 'reference/workspace/component-directory');
41
+ _defineProperty(this, "alias", 'a');
42
+ _defineProperty(this, "options", [['i', 'id <name>', 'manually set component id'], ['m', 'main <file>', 'define component entry point'], ['n', 'namespace <namespace>', 'organize component in a namespace'], ['o', 'override <boolean>', 'override existing component if exists (default = false)'], ['s', 'scope <string>', `sets the component's scope. if not entered, the default-scope from workspace.jsonc will be used`], ['e', 'env <string>', "set the component's environment. (overrides the env from variants if exists)"], ['j', 'json', 'output as json format']]);
43
+ _defineProperty(this, "loader", true);
44
+ }
45
+ async report([paths = []], addFlags) {
46
+ const {
47
+ addedComponents,
48
+ warnings
49
+ } = await this.json([paths], addFlags);
50
+ const paintWarning = () => {
51
+ const alreadyUsedOutput = () => {
52
+ const alreadyUsedWarning = Object.keys(warnings.alreadyUsed).map(key => _chalk().default.yellow(`warning: files ${_chalk().default.bold(warnings.alreadyUsed[key].join(', '))} already used by component: ${key}`)).filter(x => x).join('\n');
53
+ return alreadyUsedWarning ? `${alreadyUsedWarning}\n` : '';
54
+ };
55
+ const emptyDirectoryOutput = () => {
56
+ if (!warnings.emptyDirectory.length) return '';
57
+ return _chalk().default.yellow(`warning: the following directories are empty or all their files were excluded\n${_chalk().default.bold(warnings.emptyDirectory.join('\n'))}\n`);
58
+ };
59
+ return alreadyUsedOutput() + emptyDirectoryOutput();
60
+ };
61
+ if (addedComponents.length > 1) {
62
+ return paintWarning() + _chalk().default.green(`tracking ${addedComponents.length} new components`);
63
+ }
64
+ return paintWarning() + addedComponents.map(result => {
65
+ if (result.files.length === 0) {
66
+ return _chalk().default.underline.red(`could not track component ${_chalk().default.bold(result.id)}: no files to track`);
67
+ }
68
+ const title = _chalk().default.underline(`tracking component ${_chalk().default.bold(result.id)}:\n`);
69
+ const files = result.files.map(file => _chalk().default.green(`added ${file}`));
70
+ return title + files.join('\n');
71
+ }).flat().join('\n\n');
72
+ }
73
+ async json([paths = []], {
74
+ id,
75
+ main,
76
+ namespace,
77
+ scope,
78
+ env,
79
+ override = false
80
+ }) {
81
+ if (namespace && id) {
82
+ throw new (_bitError().BitError)('please use either [id] or [namespace] to add a particular component - they cannot be used together');
83
+ }
84
+ const normalizedPaths = paths.map(p => path().normalize(p));
85
+ const {
86
+ addedComponents,
87
+ warnings
88
+ } = await this.tracker.addForCLI({
89
+ componentPaths: normalizedPaths,
90
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
91
+ id,
92
+ main: main ? path().normalize(main) : undefined,
93
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
94
+ namespace,
95
+ defaultScope: scope,
96
+ override,
97
+ env
98
+ });
99
+ return {
100
+ addedComponents: addedComponents.map(added => ({
101
+ id: added.id.toString(),
102
+ files: added.files.map(f => f.relativePath)
103
+ })),
104
+ warnings
105
+ };
106
+ }
107
+ }
108
+ exports.AddCmd = AddCmd;
109
+
110
+ //# sourceMappingURL=add-cmd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","path","_interopRequireWildcard","_bitError","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","AddCmd","constructor","tracker","report","paths","addFlags","addedComponents","warnings","json","paintWarning","alreadyUsedOutput","alreadyUsedWarning","keys","alreadyUsed","map","key","chalk","yellow","bold","join","filter","x","emptyDirectoryOutput","emptyDirectory","length","green","result","files","underline","red","id","title","file","flat","main","namespace","scope","env","override","BitError","normalizedPaths","p","normalize","addForCLI","componentPaths","undefined","defaultScope","added","toString","relativePath","exports"],"sources":["add-cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { BitError } from '@teambit/bit-error';\nimport type { PathLinux, PathOsBased } from '@teambit/legacy.utils';\nimport type { AddActionResults, Warnings } from './add-components';\nimport type { TrackerMain } from './tracker.main.runtime';\n\ntype AddFlags = {\n id: string | null | undefined;\n main: string | null | undefined;\n namespace: string | null | undefined;\n scope?: string;\n env?: string;\n override: boolean;\n};\n\ntype AddResults = {\n addedComponents: Array<{ id: string; files: PathLinux[] }>;\n warnings: Warnings;\n};\n\nexport class AddCmd implements Command {\n name = 'add [path...]';\n description = 'track existing directory contents as new components in the workspace';\n group = 'component-development';\n extendedDescription =\n 'Registers one or more directories as Bit components without changing your files. Each provided path becomes a component root tracked by Bit.';\n helpUrl = 'reference/workspace/component-directory';\n alias = 'a';\n options = [\n ['i', 'id <name>', 'manually set component id'],\n ['m', 'main <file>', 'define component entry point'],\n ['n', 'namespace <namespace>', 'organize component in a namespace'],\n ['o', 'override <boolean>', 'override existing component if exists (default = false)'],\n [\n 's',\n 'scope <string>',\n `sets the component's scope. if not entered, the default-scope from workspace.jsonc will be used`,\n ],\n ['e', 'env <string>', \"set the component's environment. (overrides the env from variants if exists)\"],\n ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private tracker: TrackerMain) {}\n\n async report([paths = []]: [string[]], addFlags: AddFlags) {\n const { addedComponents, warnings }: AddResults = await this.json([paths], addFlags);\n\n const paintWarning = () => {\n const alreadyUsedOutput = () => {\n const alreadyUsedWarning = Object.keys(warnings.alreadyUsed)\n .map((key) =>\n chalk.yellow(\n `warning: files ${chalk.bold(warnings.alreadyUsed[key].join(', '))} already used by component: ${key}`\n )\n )\n .filter((x) => x)\n .join('\\n');\n return alreadyUsedWarning ? `${alreadyUsedWarning}\\n` : '';\n };\n const emptyDirectoryOutput = () => {\n if (!warnings.emptyDirectory.length) return '';\n return chalk.yellow(\n `warning: the following directories are empty or all their files were excluded\\n${chalk.bold(\n warnings.emptyDirectory.join('\\n')\n )}\\n`\n );\n };\n return alreadyUsedOutput() + emptyDirectoryOutput();\n };\n\n if (addedComponents.length > 1) {\n return paintWarning() + chalk.green(`tracking ${addedComponents.length} new components`);\n }\n\n return (\n paintWarning() +\n addedComponents\n .map((result) => {\n if (result.files.length === 0) {\n return chalk.underline.red(`could not track component ${chalk.bold(result.id)}: no files to track`);\n }\n const title = chalk.underline(`tracking component ${chalk.bold(result.id)}:\\n`);\n const files = result.files.map((file) => chalk.green(`added ${file}`));\n return title + files.join('\\n');\n })\n .flat()\n .join('\\n\\n')\n );\n }\n\n async json(\n [paths = []]: [string[]],\n { id, main, namespace, scope, env, override = false }: AddFlags\n ): Promise<AddResults> {\n if (namespace && id) {\n throw new BitError(\n 'please use either [id] or [namespace] to add a particular component - they cannot be used together'\n );\n }\n\n const normalizedPaths: PathOsBased[] = paths.map((p) => path.normalize(p));\n const { addedComponents, warnings }: AddActionResults = await this.tracker.addForCLI({\n componentPaths: normalizedPaths,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n id,\n main: main ? path.normalize(main) : undefined,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n namespace,\n defaultScope: scope,\n override,\n env,\n });\n return {\n addedComponents: addedComponents.map((added) => ({\n id: added.id.toString(),\n files: added.files.map((f) => f.relativePath),\n })),\n warnings,\n };\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAI,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAA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AAI,CAAC;IACjC,CAAC,CAAC,CACDc,IAAI,CAAC,CAAC,CACNd,IAAI,CAAC,MAAM,CAAC;EAEnB;EAEA,MAAMX,IAAIA,CACR,CAACJ,KAAK,GAAG,EAAE,CAAa,EACxB;IAAE0B,EAAE;IAAEI,IAAI;IAAEC,SAAS;IAAEC,KAAK;IAAEC,GAAG;IAAEC,QAAQ,GAAG;EAAgB,CAAC,EAC1C;IACrB,IAAIH,SAAS,IAAIL,EAAE,EAAE;MACnB,MAAM,KAAIS,oBAAQ,EAChB,oGACF,CAAC;IACH;IAEA,MAAMC,eAA8B,GAAGpC,KAAK,CAACU,GAAG,CAAE2B,CAAC,IAAK3E,IAAI,CAAD,CAAC,CAAC4E,SAAS,CAACD,CAAC,CAAC,CAAC;IAC1E,MAAM;MAAEnC,eAAe;MAAEC;IAA2B,CAAC,GAAG,MAAM,IAAI,CAACL,OAAO,CAACyC,SAAS,CAAC;MACnFC,cAAc,EAAEJ,eAAe;MAC/B;MACAV,EAAE;MACFI,IAAI,EAAEA,IAAI,GAAGpE,IAAI,CAAD,CAAC,CAAC4E,SAAS,CAACR,IAAI,CAAC,GAAGW,SAAS;MAC7C;MACAV,SAAS;MACTW,YAAY,EAAEV,KAAK;MACnBE,QAAQ;MACRD;IACF,CAAC,CAAC;IACF,OAAO;MACL/B,eAAe,EAAEA,eAAe,CAACQ,GAAG,CAAEiC,KAAK,KAAM;QAC/CjB,EAAE,EAAEiB,KAAK,CAACjB,EAAE,CAACkB,QAAQ,CAAC,CAAC;QACvBrB,KAAK,EAAEoB,KAAK,CAACpB,KAAK,CAACb,GAAG,CAAErC,CAAC,IAAKA,CAAC,CAACwE,YAAY;MAC9C,CAAC,CAAC,CAAC;MACH1C;IACF,CAAC;EACH;AACF;AAAC2C,OAAA,CAAAlD,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1,144 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ import type { BitMap, ComponentMapFile, Config } from '@teambit/legacy.bit-map';
3
+ import { ComponentMap } from '@teambit/legacy.bit-map';
4
+ import type { Consumer } from '@teambit/legacy.consumer';
5
+ import type { PathLinux, PathOsBased } from '@teambit/legacy.utils';
6
+ import type { Workspace } from '@teambit/workspace';
7
+ import type { ResolvedTrackData } from './tracker.main.runtime';
8
+ export type AddResult = {
9
+ id: ComponentID;
10
+ files: ComponentMapFile[];
11
+ };
12
+ export type Warnings = {
13
+ alreadyUsed: Record<string, any>;
14
+ emptyDirectory: string[];
15
+ existInScope: ComponentID[];
16
+ };
17
+ export type AddActionResults = {
18
+ addedComponents: AddResult[];
19
+ warnings: Warnings;
20
+ };
21
+ export type PathOrDSL = PathOsBased | string;
22
+ type PathsStats = {};
23
+ export type AddedComponent = {
24
+ componentId: ComponentID;
25
+ files: ComponentMapFile[];
26
+ mainFile?: PathOsBased | null | undefined;
27
+ trackDir: PathOsBased;
28
+ idFromPath: {
29
+ name: string;
30
+ namespace: string;
31
+ } | null | undefined;
32
+ immediateDir?: string;
33
+ };
34
+ export type AddProps = {
35
+ componentPaths: PathOsBased[];
36
+ id?: string;
37
+ main?: PathOsBased;
38
+ namespace?: string;
39
+ override: boolean;
40
+ trackDirFeature?: boolean;
41
+ defaultScope?: string;
42
+ config?: Config;
43
+ shouldHandleOutOfSync?: boolean;
44
+ env?: string;
45
+ };
46
+ export type AddContext = {
47
+ workspace: Workspace;
48
+ };
49
+ export default class AddComponents {
50
+ workspace: Workspace;
51
+ consumer: Consumer;
52
+ bitMap: BitMap;
53
+ componentPaths: PathOsBased[];
54
+ id: string | null | undefined;
55
+ main: PathOsBased | null | undefined;
56
+ namespace: string | null | undefined;
57
+ override: boolean;
58
+ trackDirFeature: boolean | null | undefined;
59
+ warnings: Warnings;
60
+ ignoreList: string[];
61
+ gitIgnore: any;
62
+ addedComponents: AddResult[];
63
+ defaultScope?: string;
64
+ config?: Config;
65
+ shouldHandleOutOfSync?: boolean;
66
+ constructor(context: AddContext, addProps: AddProps);
67
+ add(): Promise<AddActionResults>;
68
+ /**
69
+ * @param {string[]} files - array of file-paths from which it should search for the dsl patterns.
70
+ * @param {*} filesWithPotentialDsl - array of file-path which may have DSL patterns
71
+ *
72
+ * @returns array of file-paths from 'files' parameter that match the patterns from 'filesWithPotentialDsl' parameter
73
+ */
74
+ getFilesAccordingToDsl(files: PathLinux[], filesWithPotentialDsl: PathOrDSL[]): Promise<PathLinux[]>;
75
+ /**
76
+ * for imported component, the package.json in the root directory is a bit-generated file and as
77
+ * such, it should be ignored
78
+ */
79
+ _isPackageJsonOnRootDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap): boolean;
80
+ /**
81
+ * imported components might have wrapDir, when they do, files should not be added outside of
82
+ * that wrapDir
83
+ */
84
+ _isOutsideOfWrapDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap): boolean;
85
+ /**
86
+ * Add or update existing (imported and new) component according to bitmap
87
+ * there are 3 options:
88
+ * 1. a user is adding a new component. there is no record for this component in bit.map
89
+ * 2. a user is updating an existing component. there is a record for this component in bit.map
90
+ * 3. some or all the files of this component were previously added as another component-id.
91
+ */
92
+ addOrUpdateComponentInBitMap(component: AddedComponent): Promise<AddResult | null | undefined>;
93
+ /**
94
+ * current componentFiles are relative to the workspace. we want them relative to the rootDir.
95
+ */
96
+ _updateFilesAccordingToExistingRootDir(foundComponentFromBitMap: ComponentMap, componentFiles: ComponentMapFile[], component: AddedComponent): void;
97
+ /**
98
+ * the risk with merging the currently added files with the existing bitMap files is overriding
99
+ * the `test` property. e.g. the component directory is re-added without adding the tests flag to
100
+ * track new files in that directory. in this case, we want to preserve the `test` property.
101
+ */
102
+ _mergeFilesWithExistingComponentMapFiles(componentFiles: ComponentMapFile[], existingComponentMapFile: ComponentMapFile[]): ComponentMapFile[];
103
+ /**
104
+ * if an existing file is for example uppercase and the new file is lowercase it has different
105
+ * behavior according to the OS. some OS are case sensitive, some are not.
106
+ * it's safer to avoid saving both files and instead, replacing the old file with the new one.
107
+ * in case a file has replaced and it is also a mainFile, replace the mainFile as well
108
+ */
109
+ _updateFilesWithCurrentLetterCases(currentComponentMap: ComponentMap, newFiles: ComponentMapFile[]): void;
110
+ /**
111
+ * if the id is already saved in bitmap file, it might have more data (such as scope, version)
112
+ * use that id instead.
113
+ */
114
+ private _getIdAccordingToExistingComponent;
115
+ _getIdAccordingToTrackDir(dir: PathOsBased): ComponentID | null | undefined;
116
+ /**
117
+ * used for updating main file if exists or doesn't exists
118
+ */
119
+ _addMainFileToFiles(files: ComponentMapFile[]): PathOsBased | null | undefined;
120
+ _findMainFileInFiles(mainFile: string, files: ComponentMapFile[]): ComponentMapFile | undefined;
121
+ private getDefaultScope;
122
+ /**
123
+ * given the component paths, prepare the id, mainFile and files to be added later on to bitmap
124
+ * the id of the component is either entered by the user or, if not entered, concluded by the path.
125
+ * e.g. bar/foo.js, the id would be bar/foo.
126
+ * in case bitmap has already the same id, the complete id is taken from bitmap (see _getIdAccordingToExistingComponent)
127
+ */
128
+ addOneComponent(componentPath: PathOsBased): Promise<AddedComponent>;
129
+ getIgnoreList(): Promise<string[]>;
130
+ linkComponents(ids: ComponentID[]): Promise<void>;
131
+ addMultipleComponents(componentPathsStats: PathsStats): Promise<void>;
132
+ /**
133
+ * some uses of wildcards might add directories and their files at the same time, in such cases
134
+ * only the files are needed and the directories can be ignored.
135
+ * @see https://github.com/teambit/bit/issues/1406 for more details
136
+ */
137
+ _removeDirectoriesWhenTheirFilesAreAdded(componentPathsStats: PathsStats): void;
138
+ _addMultipleToBitMap(added: AddedComponent[]): Promise<void>;
139
+ _removeNamespaceIfNotNeeded(addedComponents: AddedComponent[]): Promise<void>;
140
+ _tryAddingMultiple(componentPathsStats: PathsStats): Promise<AddedComponent[]>;
141
+ _throwForOutsideConsumer(relativeToConsumerPath: PathOsBased): void;
142
+ }
143
+ export declare function addMultipleFromResolvedTrackData(workspace: Workspace, trackData: ResolvedTrackData[]): Promise<ComponentID[]>;
144
+ export {};