diff --git a/src/commands/dependencies/copy.ts b/src/commands/dependencies/copy.ts index e4f47d4..439c0aa 100644 --- a/src/commands/dependencies/copy.ts +++ b/src/commands/dependencies/copy.ts @@ -3,30 +3,35 @@ import { Command } from 'commander' import { cliConfig } from '../../config/cli.config' import { projectConfig } from '../../config/project.config' import { composeExec } from '../../utils/compose' -import { noIndent } from '../../utils/string' export function depsCopyCommand() { return new Command() .name('copy') .summary('Copy dependencies from containers to local repository') - .description( - noIndent(` - Copy dependencies from containers to local repository to enable - IDE features such as IntelliSense. - `), - ) .action(() => { - const { repositories, projectName } = projectConfig.load() + const { repositories, projectName, projectType, monoRepoServices } = projectConfig.load() const { reposPath } = cliConfig.load() - for (const repo in repositories) { - composeExec({ - command: [ - 'cp', - `${repo.replace(`${projectName}-`, '')}:/usr/app/node_modules`, - join(reposPath, repo, 'node_modules'), - ], - }) + if (projectType === 'MonoRepo' && monoRepoServices) { + for (const path of projectConfig.repoServicesPaths()) { + composeExec({ + command: [ + 'cp', + `${path.split('/').slice(-1)}:/usr/app/node_modules`, + join(path, 'node_modules'), + ], + }) + } + } else { + for (const repo in repositories) { + composeExec({ + command: [ + 'cp', + `${repo.replace(`${projectName}-`, '')}:/usr/app/node_modules`, + join(reposPath, repo, 'node_modules'), + ], + }) + } } }) }