-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28d2320
commit fee6c21
Showing
4 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@icebreakers/monorepo", | ||
"type": "module", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"description": "icebreaker's monorepo config generator", | ||
"author": "ice breaker <[email protected]>", | ||
"license": "MIT", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './lib' | ||
export * from './monorepo' | ||
export * from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import os from 'node:os' | ||
import { execa } from 'execa' | ||
import PQueue from 'p-queue' | ||
import pc from 'picocolors' | ||
import { logger } from '../logger' | ||
import { getWorkspacePackages } from './workspace' | ||
|
||
export async function syncNpmMirror(cwd: string) { | ||
const packages = await getWorkspacePackages(cwd) | ||
logger.info(`[即将同步的包]:\n${packages.filter(x => x.manifest.name).map(x => `- ${pc.green(x.manifest.name)}`).join('\n')}\n`) | ||
for ( | ||
const project of packages | ||
) { | ||
if (project.manifest.name) { | ||
await execa({ | ||
stdout: ['pipe', 'inherit'], | ||
})`cnpm sync ${project.manifest.name}` | ||
const set = new Set(packages.map(x => x.manifest.name)) | ||
logger.info(`[即将同步的包]:\n${Array.from(set).map(x => `- ${pc.green(x)}`).join('\n')}\n`) | ||
const concurrency = Math.max(os.cpus().length, 1) | ||
const queue = new PQueue({ concurrency }) | ||
for (const pkgName of set) { | ||
if (pkgName) { | ||
await queue.add(async () => { | ||
return execa({ | ||
stdout: ['pipe', 'inherit'], | ||
})`cnpm sync ${pkgName}` | ||
}) | ||
} | ||
} | ||
} |