@@ -5,7 +5,6 @@ import * as path from 'path';
5
5
import { type IMinimatch , Minimatch } from 'minimatch' ;
6
6
import semver from 'semver' ;
7
7
import npmPacklist from 'npm-packlist' ;
8
- import pnpmLinkBins from '@pnpm/link-bins' ;
9
8
import ignore , { type Ignore } from 'ignore' ;
10
9
import {
11
10
Async ,
@@ -20,8 +19,18 @@ import { Colorize, type ITerminal } from '@rushstack/terminal';
20
19
21
20
import { SymlinkAnalyzer , type ILinkInfo , type PathNode } from './SymlinkAnalyzer' ;
22
21
import { AssetHandler } from './AssetHandler' ;
23
- import { matchesWithStar , remapSourcePathForTargetFolder , remapPathForExtractorMetadata } from './Utils' ;
24
- import { createLinksScriptFilename , scriptsFolderPath } from './PathConstants' ;
22
+ import {
23
+ matchesWithStar ,
24
+ remapSourcePathForTargetFolder ,
25
+ remapPathForExtractorMetadata ,
26
+ makeBinLinksAsync
27
+ } from './Utils' ;
28
+ import {
29
+ CREATE_LINKS_SCRIPT_FILENAME ,
30
+ EXTRACTOR_METADATA_FILENAME ,
31
+ SCRIPTS_FOLDER_PATH
32
+ } from './PathConstants' ;
33
+ import { MAX_CONCURRENCY } from './scripts/createLinks/utilities/constants' ;
25
34
26
35
// (@types/npm-packlist is missing this API)
27
36
declare module 'npm-packlist' {
@@ -479,7 +488,7 @@ export class PackageExtractor {
479
488
await this . _extractFolderAsync ( folderToCopy , options , state ) ;
480
489
} ,
481
490
{
482
- concurrency : 10
491
+ concurrency : MAX_CONCURRENCY
483
492
}
484
493
) ;
485
494
@@ -640,7 +649,7 @@ export class PackageExtractor {
640
649
callback ( ) ;
641
650
} ,
642
651
{
643
- concurrency : 10
652
+ concurrency : MAX_CONCURRENCY
644
653
}
645
654
) ;
646
655
}
@@ -799,7 +808,7 @@ export class PackageExtractor {
799
808
}
800
809
} ,
801
810
{
802
- concurrency : 10
811
+ concurrency : MAX_CONCURRENCY
803
812
}
804
813
) ;
805
814
} else {
@@ -867,7 +876,7 @@ export class PackageExtractor {
867
876
callback ( ) ;
868
877
} ,
869
878
{
870
- concurrency : 10
879
+ concurrency : MAX_CONCURRENCY
871
880
}
872
881
) ;
873
882
}<
10000
/span>
@@ -884,14 +893,13 @@ export class PackageExtractor {
884
893
options ;
885
894
const { projectConfigurationsByPath } = state ;
886
895
887
- const extractorMetadataFileName : string = 'extractor-metadata.json' ;
888
896
const extractorMetadataFolderPath : string =
889
897
linkCreation === 'script' && linkCreationScriptPath
890
898
? path . dirname ( path . resolve ( targetRootFolder , linkCreationScriptPath ) )
891
899
: targetRootFolder ;
892
900
const extractorMetadataFilePath : string = path . join (
893
901
extractorMetadataFolderPath ,
894
- extractorMetadataFileName
902
+ EXTRACTOR_METADATA_FILENAME
895
903
) ;
896
904
const extractorMetadataJson : IExtractorMetadataJson = {
897
905
mainProjectName,
@@ -932,41 +940,21 @@ export class PackageExtractor {
932
940
private async _makeBinLinksAsync ( options : IExtractorOptions , state : IExtractorState ) : Promise < void > {
933
941
const { terminal } = options ;
934
942
935
- const extractedProjectFolders : string [ ] = Array . from ( state . projectConfigurationsByPath . keys ( ) ) . filter (
936
- ( folderPath : string ) => state . foldersToCopy . has ( folderPath )
937
- ) ;
938
-
939
- await Async . forEachAsync (
940
- extractedProjectFolders ,
941
- async ( projectFolder : string ) => {
942
- const extractedProjectFolder : string = remapSourcePathForTargetFolder ( {
943
- ...options ,
944
- sourcePath : projectFolder
945
- } ) ;
946
- const extractedProjectNodeModulesFolder : string = path . join ( extractedProjectFolder , 'node_modules' ) ;
947
- const extractedProjectBinFolder : string = path . join ( extractedProjectNodeModulesFolder , '.bin' ) ;
948
-
949
- const linkedBinPackageNames : string [ ] = await pnpmLinkBins (
950
- extractedProjectNodeModulesFolder ,
951
- extractedProjectBinFolder ,
952
- {
953
- warn : ( msg : string ) => terminal . writeLine ( Colorize . yellow ( msg ) )
954
- }
943
+ const extractedProjectFolderPaths : string [ ] = [ ] ;
944
+ for ( const folderPath of state . projectConfigurationsByPath . keys ( ) ) {
945
+ if ( state . foldersToCopy . has ( folderPath ) ) {
946
+ extractedProjectFolderPaths . push (
947
+ remapSourcePathForTargetFolder ( { ...options , sourcePath : folderPath } )
955
948
) ;
949
+ }
950
+ }
956
951
957
- if ( linkedBinPackageNames . length ) {
958
- const binFolderItems : string [ ] =
959
- await FileSystem . readFolderItemNamesAsync ( extractedProjectBinFolder ) ;
960
- for ( const binFolderItem of binFolderItems ) {
961
- const binFilePath : string = path . resolve ( extractedProjectBinFolder , binFolderItem ) ;
962
- await state . assetHandler . includeAssetAsync ( {
963
- targetFilePath : binFilePath
964
- } ) ;
965
- }
966
- }
967
- } ,
952
+ const binFilePaths : string [ ] = await makeBinLinksAsync ( terminal , extractedProjectFolderPaths ) ;
953
+ await Async . forEachAsync (
954
+ binFilePaths ,
955
+ ( targetFilePath : string ) => state . assetHandler . includeAssetAsync ( { targetFilePath } ) ,
968
956
{
969
- concurrency : 10
957
+ concurrency : MAX_CONCURRENCY
970
958
}
971
959
) ;
972
960
}
@@ -978,11 +966,11 @@ export class PackageExtractor {
978
966
const { terminal, targetRootFolder, linkCreationScriptPath } = options ;
979
967
const { assetHandler } = state ;
980
968
981
- terminal . writeLine ( `Creating ${ createLinksScriptFilename } ` ) ;
982
- const createLinksSourceFilePath : string = `${ scriptsFolderPath } /${ createLinksScriptFilename } ` ;
969
+ terminal . writeLine ( `Creating ${ CREATE_LINKS_SCRIPT_FILENAME } ` ) ;
970
+ const createLinksSourceFilePath : string = `${ SCRIPTS_FOLDER_PATH } /${ CREATE_LINKS_SCRIPT_FILENAME } ` ;
983
971
const createLinksTargetFilePath : string = path . resolve (
984
972
targetRootFolder ,
985
- linkCreationScriptPath || createLinksScriptFilename
973
+ linkCreationScriptPath || CREATE_LINKS_SCRIPT_FILENAME
986
974
) ;
987
975
let createLinksScriptContent : string = await FileSystem . readFileAsync ( createLinksSourceFilePath ) ;
988
976
createLinksScriptContent = createLinksScriptContent . replace (
0 commit comments