Skip to content

Commit

Permalink
improvement(doctor) - remove some folders from bit doctor --archive (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
GiladShoham authored Apr 9, 2024
1 parent 7559ea0 commit 2c1db58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/api/consumer/lib/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type DoctorOptions = {
filePath?: string;
archiveWorkspace?: boolean;
includeNodeModules?: boolean;
includePublic?: boolean;
excludeLocalScope?: boolean;
};

Expand Down Expand Up @@ -145,7 +146,7 @@ async function _generateExamineResultsTarFile(
tarFilePath: string,
options: DoctorOptions
): Promise<Stream.Readable> {
const { archiveWorkspace, includeNodeModules, excludeLocalScope } = options;
const { archiveWorkspace, includeNodeModules, includePublic, excludeLocalScope } = options;
const debugLog = await _getDebugLogAsBuffer();
const consumerInfo = await _getConsumerInfo();
let bitmap;
Expand Down Expand Up @@ -184,9 +185,21 @@ async function _generateExamineResultsTarFile(

const ignore = (fileName: string) => {
if (fileName === tarFilePath) return true;
if (!includeNodeModules && fileName.startsWith(`node_modules${path.sep}`)) return true;
if (fileName === '.DS_Store') return true;
if (
!includeNodeModules &&
(fileName.startsWith(`node_modules${path.sep}`) || fileName.includes(`${path.sep}node_modules${path.sep}`))
)
return true;
if (
!includePublic &&
(fileName.startsWith(`public${path.sep}`) || fileName.includes(`${path.sep}public${path.sep}`))
)
return true;
const isGit = fileName.startsWith(`.git${path.sep}`);
const isLocalScope = fileName.startsWith(`.bit${path.sep}`) || fileName.startsWith(`.git${path.sep}bit${path.sep}`);
if (excludeLocalScope && isLocalScope) return true;
if (isGit && !isLocalScope) return true;
return false;
};

Expand Down
4 changes: 4 additions & 0 deletions src/cli/commands/public-cmds/doctor-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class Doctor implements LegacyCommand {
'archive the workspace including diagnosis info (by default exclude node-modules and include .bit)',
],
['n', 'include-node-modules', 'relevant for --archive. include node_modules in the archive file'],
['p', 'include-public', 'relevant for --archive. include public folder in the archive file'],
['e', 'exclude-local-scope', 'relevant for --archive. exclude .bit or .git/bit from the archive file'],
] as CommandOptions;

Expand All @@ -36,12 +37,14 @@ export default class Doctor implements LegacyCommand {
save,
archive,
includeNodeModules = false,
includePublic = false,
excludeLocalScope = false,
}: {
list?: boolean;
save?: string;
archive?: string;
includeNodeModules?: boolean;
includePublic?: boolean;
excludeLocalScope?: boolean;
}
): Promise<DoctorRunAllResults | Diagnosis[] | DoctorRunOneResult> {
Expand All @@ -65,6 +68,7 @@ export default class Doctor implements LegacyCommand {
filePath,
archiveWorkspace: Boolean(archive),
includeNodeModules,
includePublic,
excludeLocalScope,
};
return diagnosisName ? runOne(doctorOptions) : runAll(doctorOptions);
Expand Down

0 comments on commit 2c1db58

Please sign in to comment.