Skip to content

Commit

Permalink
chore: Fix copy dependencies command for monorepo services
Browse files Browse the repository at this point in the history
  • Loading branch information
angelmadames committed Jul 26, 2024
1 parent d97d0e2 commit fa97ba3
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/commands/dependencies/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
})
}
}
})
}

0 comments on commit fa97ba3

Please sign in to comment.