@teambit/tracker 0.0.1
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/add-cmd.d.ts +22 -0
- package/dist/add-cmd.js +110 -0
- package/dist/add-cmd.js.map +1 -0
- package/dist/add-components.d.ts +151 -0
- package/dist/add-components.js +918 -0
- package/dist/add-components.js.map +1 -0
- package/dist/determine-main-file.d.ts +4 -0
- package/dist/determine-main-file.js +154 -0
- package/dist/determine-main-file.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/preview-1674876551482.js +7 -0
- package/dist/tracker.aspect.d.ts +2 -0
- package/dist/tracker.aspect.js +19 -0
- package/dist/tracker.aspect.js.map +1 -0
- package/dist/tracker.main.runtime.d.ts +48 -0
- package/dist/tracker.main.runtime.js +141 -0
- package/dist/tracker.main.runtime.js.map +1 -0
- package/package-tar/teambit-tracker-0.0.1.tgz +0 -0
- package/package.json +60 -0
- package/tsconfig.json +40 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { TrackerMain } from './tracker.main.runtime';
|
|
3
|
+
export declare class AddCmd implements Command {
|
|
4
|
+
private tracker;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
group: string;
|
|
8
|
+
extendedDescription: string;
|
|
9
|
+
helpUrl: string;
|
|
10
|
+
alias: string;
|
|
11
|
+
options: CommandOptions;
|
|
12
|
+
loader: boolean;
|
|
13
|
+
migration: boolean;
|
|
14
|
+
constructor(tracker: TrackerMain);
|
|
15
|
+
report([paths]: [string[]], { id, main, namespace, scope, override, }: {
|
|
16
|
+
id: string | null | undefined;
|
|
17
|
+
main: string | null | undefined;
|
|
18
|
+
namespace: string | null | undefined;
|
|
19
|
+
scope?: string;
|
|
20
|
+
override: boolean;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
}
|
package/dist/add-cmd.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
require("core-js/modules/es.array.iterator.js");
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.AddCmd = void 0;
|
|
10
|
+
function _defineProperty2() {
|
|
11
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
_defineProperty2 = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _chalk() {
|
|
18
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
19
|
+
_chalk = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function path() {
|
|
25
|
+
const data = _interopRequireWildcard(require("path"));
|
|
26
|
+
path = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _bitError() {
|
|
32
|
+
const data = require("@teambit/bit-error");
|
|
33
|
+
_bitError = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function _ramda() {
|
|
39
|
+
const data = _interopRequireDefault(require("ramda"));
|
|
40
|
+
_ramda = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
46
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
47
|
+
class AddCmd {
|
|
48
|
+
constructor(tracker) {
|
|
49
|
+
this.tracker = tracker;
|
|
50
|
+
(0, _defineProperty2().default)(this, "name", 'add [path...]');
|
|
51
|
+
(0, _defineProperty2().default)(this, "description", 'Add any subset of files to be tracked as a component(s).');
|
|
52
|
+
(0, _defineProperty2().default)(this, "group", 'development');
|
|
53
|
+
(0, _defineProperty2().default)(this, "extendedDescription", 'Learn the recommended workflow for tracking directories as components, in the link below.');
|
|
54
|
+
(0, _defineProperty2().default)(this, "helpUrl", 'docs/workspace/creating-workspaces?new_existing_project=1');
|
|
55
|
+
(0, _defineProperty2().default)(this, "alias", 'a');
|
|
56
|
+
(0, _defineProperty2().default)(this, "options", [['i', 'id <name>', 'manually set component id'], ['m', 'main <file>', 'define entry point for the components'], ['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-name. if not entered, the default-scope will be used`]]);
|
|
57
|
+
(0, _defineProperty2().default)(this, "loader", true);
|
|
58
|
+
(0, _defineProperty2().default)(this, "migration", true);
|
|
59
|
+
}
|
|
60
|
+
async report([paths = []], {
|
|
61
|
+
id,
|
|
62
|
+
main,
|
|
63
|
+
namespace,
|
|
64
|
+
scope,
|
|
65
|
+
override = false
|
|
66
|
+
}) {
|
|
67
|
+
if (namespace && id) {
|
|
68
|
+
throw new (_bitError().BitError)('please use either [id] or [namespace] to add a particular component');
|
|
69
|
+
}
|
|
70
|
+
const normalizedPaths = paths.map(p => path().normalize(p));
|
|
71
|
+
const {
|
|
72
|
+
addedComponents,
|
|
73
|
+
warnings
|
|
74
|
+
} = await this.tracker.addForCLI({
|
|
75
|
+
componentPaths: normalizedPaths,
|
|
76
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
77
|
+
id,
|
|
78
|
+
main: main ? path().normalize(main) : undefined,
|
|
79
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
80
|
+
namespace,
|
|
81
|
+
defaultScope: scope,
|
|
82
|
+
override
|
|
83
|
+
});
|
|
84
|
+
const paintWarning = () => {
|
|
85
|
+
const alreadyUsedOutput = () => {
|
|
86
|
+
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');
|
|
87
|
+
return _ramda().default.isEmpty(alreadyUsedWarning) ? '' : `${alreadyUsedWarning}\n`;
|
|
88
|
+
};
|
|
89
|
+
const emptyDirectoryOutput = () => {
|
|
90
|
+
if (!warnings.emptyDirectory.length) return '';
|
|
91
|
+
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`);
|
|
92
|
+
};
|
|
93
|
+
return alreadyUsedOutput() + emptyDirectoryOutput();
|
|
94
|
+
};
|
|
95
|
+
if (addedComponents.length > 1) {
|
|
96
|
+
return paintWarning() + _chalk().default.green(`tracking ${addedComponents.length} new components`);
|
|
97
|
+
}
|
|
98
|
+
return paintWarning() + _ramda().default.flatten(addedComponents.map(result => {
|
|
99
|
+
if (result.files.length === 0) {
|
|
100
|
+
return _chalk().default.underline.red(`could not track component ${_chalk().default.bold(result.id.toString())}: no files to track`);
|
|
101
|
+
}
|
|
102
|
+
const title = _chalk().default.underline(`tracking component ${_chalk().default.bold(result.id.toString())}:\n`);
|
|
103
|
+
const files = result.files.map(file => _chalk().default.green(`added ${file.relativePath}`));
|
|
104
|
+
return title + files.join('\n');
|
|
105
|
+
})).join('\n\n');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.AddCmd = AddCmd;
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=add-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AddCmd","constructor","tracker","report","paths","id","main","namespace","scope","override","BitError","normalizedPaths","map","p","path","normalize","addedComponents","warnings","addForCLI","componentPaths","undefined","defaultScope","paintWarning","alreadyUsedOutput","alreadyUsedWarning","Object","keys","alreadyUsed","key","chalk","yellow","bold","join","filter","x","R","isEmpty","emptyDirectoryOutput","emptyDirectory","length","green","flatten","result","files","underline","red","toString","title","file","relativePath"],"sources":["add-cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport { BitError } from '@teambit/bit-error';\nimport { PathOsBased } from '@teambit/legacy/dist/utils/path';\nimport R from 'ramda';\nimport { AddActionResults, AddResult } from './add-components';\nimport { TrackerMain } from './tracker.main.runtime';\n\nexport class AddCmd implements Command {\n name = 'add [path...]';\n description = 'Add any subset of files to be tracked as a component(s).';\n group = 'development';\n extendedDescription = 'Learn the recommended workflow for tracking directories as components, in the link below.';\n helpUrl = 'docs/workspace/creating-workspaces?new_existing_project=1';\n alias = 'a';\n options = [\n ['i', 'id <name>', 'manually set component id'],\n ['m', 'main <file>', 'define entry point for the components'],\n ['n', 'namespace <namespace>', 'organize component in a namespace'],\n ['o', 'override <boolean>', 'override existing component if exists (default = false)'],\n ['s', 'scope <string>', `sets the component's scope-name. if not entered, the default-scope will be used`],\n ] as CommandOptions;\n loader = true;\n migration = true;\n\n constructor(private tracker: TrackerMain) {}\n\n async report(\n [paths = []]: [string[]],\n {\n id,\n main,\n namespace,\n scope,\n override = false,\n }: {\n id: string | null | undefined;\n main: string | null | undefined;\n namespace: string | null | undefined;\n scope?: string;\n override: boolean;\n }\n ) {\n if (namespace && id) {\n throw new BitError('please use either [id] or [namespace] to add a particular component');\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 });\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 R.isEmpty(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 R.flatten(\n addedComponents.map((result: AddResult) => {\n if (result.files.length === 0) {\n return chalk.underline.red(\n `could not track component ${chalk.bold(result.id.toString())}: no files to track`\n );\n }\n const title = chalk.underline(`tracking component ${chalk.bold(result.id.toString())}:\\n`);\n const files = result.files.map((file) => chalk.green(`added ${file.relativePath}`));\n return title + files.join('\\n');\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CAACM,OAAO,CACPzB,eAAe,CAACJ,GAAG,CAAE8B,MAAiB,IAAK;MACzC,IAAIA,MAAM,CAACC,KAAK,CAACJ,MAAM,KAAK,CAAC,EAAE;QAC7B,OAAOV,gBAAK,CAACe,SAAS,CAACC,GAAG,CACvB,6BAA4BhB,gBAAK,CAACE,IAAI,CAACW,MAAM,CAACrC,EAAE,CAACyC,QAAQ,EAAE,CAAE,qBAAoB,CACnF;MACH;MACA,MAAMC,KAAK,GAAGlB,gBAAK,CAACe,SAAS,CAAE,sBAAqBf,gBAAK,CAACE,IAAI,CAACW,MAAM,CAACrC,EAAE,CAACyC,QAAQ,EAAE,CAAE,KAAI,CAAC;MAC1F,MAAMH,KAAK,GAAGD,MAAM,CAACC,KAAK,CAAC/B,GAAG,CAAEoC,IAAI,IAAKnB,gBAAK,CAACW,KAAK,CAAE,SAAQQ,IAAI,CAACC,YAAa,EAAC,CAAC,CAAC;MACnF,OAAOF,KAAK,GAAGJ,KAAK,CAACX,IAAI,CAAC,IAAI,CAAC;IACjC,CAAC,CAAC,CACH,CAACA,IAAI,CAAC,MAAM,CAAC;EAElB;AACF;AAAC"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { BitId } from '@teambit/legacy/dist/bit-id';
|
|
2
|
+
import { BitIdStr } from '@teambit/legacy/dist/bit-id/bit-id';
|
|
3
|
+
import BitMap from '@teambit/legacy/dist/consumer/bit-map';
|
|
4
|
+
import Consumer from '@teambit/legacy/dist/consumer/consumer';
|
|
5
|
+
import { ModelComponent } from '@teambit/legacy/dist/scope/models';
|
|
6
|
+
import { PathLinux, PathOsBased } from '@teambit/legacy/dist/utils/path';
|
|
7
|
+
import ComponentMap, { ComponentMapFile, Config } from '@teambit/legacy/dist/consumer/bit-map/component-map';
|
|
8
|
+
export declare type AddResult = {
|
|
9
|
+
id: BitId;
|
|
10
|
+
files: ComponentMapFile[];
|
|
11
|
+
};
|
|
12
|
+
export declare type Warnings = {
|
|
13
|
+
alreadyUsed: Record<string, any>;
|
|
14
|
+
emptyDirectory: string[];
|
|
15
|
+
existInScope: BitId[];
|
|
16
|
+
};
|
|
17
|
+
export declare type AddActionResults = {
|
|
18
|
+
addedComponents: AddResult[];
|
|
19
|
+
warnings: Warnings;
|
|
20
|
+
};
|
|
21
|
+
export declare type PathOrDSL = PathOsBased | string;
|
|
22
|
+
declare type PathsStats = {};
|
|
23
|
+
export declare type AddedComponent = {
|
|
24
|
+
componentId: BitId;
|
|
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 declare 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
|
+
};
|
|
45
|
+
export declare type AddContext = {
|
|
46
|
+
consumer: Consumer;
|
|
47
|
+
alternateCwd?: string;
|
|
48
|
+
};
|
|
49
|
+
export default class AddComponents {
|
|
50
|
+
consumer: Consumer;
|
|
51
|
+
bitMap: BitMap;
|
|
52
|
+
componentPaths: PathOsBased[];
|
|
53
|
+
id: string | null | undefined;
|
|
54
|
+
main: PathOsBased | null | undefined;
|
|
55
|
+
namespace: string | null | undefined;
|
|
56
|
+
override: boolean;
|
|
57
|
+
trackDirFeature: boolean | null | undefined;
|
|
58
|
+
warnings: Warnings;
|
|
59
|
+
ignoreList: string[];
|
|
60
|
+
gitIgnore: any;
|
|
61
|
+
alternateCwd: string | null | undefined;
|
|
62
|
+
addedComponents: AddResult[];
|
|
63
|
+
defaultScope?: string;
|
|
64
|
+
config?: Config;
|
|
65
|
+
shouldHandleOutOfSync?: boolean;
|
|
66
|
+
constructor(context: AddContext, addProps: AddProps);
|
|
67
|
+
joinConsumerPathIfNeeded(paths: PathOrDSL[]): PathOrDSL[];
|
|
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
|
+
* unsupported files, such as, binary files, don't have link-file. instead, they have a symlink
|
|
77
|
+
* inside the component dir, pointing to the dependency.
|
|
78
|
+
* this methods check whether a file is auto generated for the unsupported files.
|
|
79
|
+
*/
|
|
80
|
+
_isGeneratedForUnsupportedFiles(fileRelativePath: PathLinux, componentId: BitId, componentMap: ComponentMap): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* for imported component, the package.json in the root directory is a bit-generated file and as
|
|
83
|
+
* such, it should be ignored
|
|
84
|
+
*/
|
|
85
|
+
_isPackageJsonOnRootDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* imported components might have wrapDir, when they do, files should not be added outside of
|
|
88
|
+
* that wrapDir
|
|
89
|
+
*/
|
|
90
|
+
_isOutsideOfWrapDir(pathRelativeToConsumerRoot: PathLinux, componentMap: ComponentMap): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Add or update existing (imported and new) component according to bitmap
|
|
93
|
+
* there are 3 options:
|
|
94
|
+
* 1. a user is adding a new component. there is no record for this component in bit.map
|
|
95
|
+
* 2. a user is updating an existing component. there is a record for this component in bit.map
|
|
96
|
+
* 3. some or all the files of this component were previously added as another component-id.
|
|
97
|
+
*/
|
|
98
|
+
addOrUpdateComponentInBitMap(component: AddedComponent): Promise<AddResult | null | undefined>;
|
|
99
|
+
/**
|
|
100
|
+
* current componentFiles are relative to the workspace. we want them relative to the rootDir.
|
|
101
|
+
*/
|
|
102
|
+
_updateFilesAccordingToExistingRootDir(foundComponentFromBitMap: ComponentMap, componentFiles: ComponentMapFile[], component: AddedComponent): void;
|
|
103
|
+
/**
|
|
104
|
+
* the risk with merging the currently added files with the existing bitMap files is overriding
|
|
105
|
+
* the `test` property. e.g. the component directory is re-added without adding the tests flag to
|
|
106
|
+
* track new files in that directory. in this case, we want to preserve the `test` property.
|
|
107
|
+
*/
|
|
108
|
+
_mergeFilesWithExistingComponentMapFiles(componentFiles: ComponentMapFile[], existingComponentMapFile: ComponentMapFile[]): any;
|
|
109
|
+
/**
|
|
110
|
+
* if an existing file is for example uppercase and the new file is lowercase it has different
|
|
111
|
+
* behavior according to the OS. some OS are case sensitive, some are not.
|
|
112
|
+
* it's safer to avoid saving both files and instead, replacing the old file with the new one.
|
|
113
|
+
* in case a file has replaced and it is also a mainFile, replace the mainFile as well
|
|
114
|
+
*/
|
|
115
|
+
_updateFilesWithCurrentLetterCases(currentComponentMap: ComponentMap, newFiles: ComponentMapFile[]): void;
|
|
116
|
+
_getComponentFromScopeIfExist(id: BitId): Promise<ModelComponent | null | undefined>;
|
|
117
|
+
/**
|
|
118
|
+
* if the id is already saved in bitmap file, it might have more data (such as scope, version)
|
|
119
|
+
* use that id instead.
|
|
120
|
+
*/
|
|
121
|
+
_getIdAccordingToExistingComponent(currentId: BitIdStr): BitId;
|
|
122
|
+
_getIdAccordingToTrackDir(dir: PathOsBased): BitId | null | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* used for updating main file if exists or doesn't exists
|
|
125
|
+
*/
|
|
126
|
+
_addMainFileToFiles(files: ComponentMapFile[]): PathOsBased | null | undefined;
|
|
127
|
+
_findMainFileInFiles(mainFile: string, files: ComponentMapFile[]): ComponentMapFile | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* given the component paths, prepare the id, mainFile and files to be added later on to bitmap
|
|
130
|
+
* the id of the component is either entered by the user or, if not entered, concluded by the path.
|
|
131
|
+
* e.g. bar/foo.js, the id would be bar/foo.
|
|
132
|
+
* in case bitmap has already the same id, the complete id is taken from bitmap (see _getIdAccordingToExistingComponent)
|
|
133
|
+
*/
|
|
134
|
+
addOneComponent(componentPathsStats: PathsStats): Promise<AddedComponent>;
|
|
135
|
+
getIgnoreList(): string[];
|
|
136
|
+
add(): Promise<AddActionResults>;
|
|
137
|
+
linkComponents(ids: BitId[]): Promise<void>;
|
|
138
|
+
addMultipleComponents(componentPathsStats: PathsStats): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* some uses of wildcards might add directories and their files at the same time, in such cases
|
|
141
|
+
* only the files are needed and the directories can be ignored.
|
|
142
|
+
* @see https://github.com/teambit/bit/issues/1406 for more details
|
|
143
|
+
*/
|
|
144
|
+
_removeDirectoriesWhenTheirFilesAreAdded(componentPathsStats: PathsStats): void;
|
|
145
|
+
_addMultipleToBitMap(added: AddedComponent[]): Promise<void>;
|
|
146
|
+
_removeNamespaceIfNotNeeded(addedComponents: AddedComponent[]): void;
|
|
147
|
+
_tryAddingMultiple(componentPathsStats: PathsStats): Promise<AddedComponent[]>;
|
|
148
|
+
_throwForOutsideConsumer(relativeToConsumerPath: PathOsBased): void;
|
|
149
|
+
private throwForExistingParentDir;
|
|
150
|
+
}
|
|
151
|
+
export {};
|