@rushstack/package-extractor 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.PackageExtractor = exports.TARGET_ROOT_SCRIPT_RELATIVE_PATH_TEMPLATE_STRING = void 0;
32
32
  const path = __importStar(require("path"));
33
- const fs = __importStar(require("fs"));
34
33
  const minimatch_1 = require("minimatch");
35
34
  const semver_1 = __importDefault(require("semver"));
36
35
  const npm_packlist_1 = __importDefault(require("npm-packlist"));
@@ -38,8 +37,8 @@ const link_bins_1 = __importDefault(require("@pnpm/link-bins"));
38
37
  const ignore_1 = __importDefault(require("ignore"));
39
38
  const node_core_library_1 = require("@rushstack/node-core-library");
40
39
  const terminal_1 = require("@rushstack/terminal");
41
- const ArchiveManager_1 = require("./ArchiveManager");
42
40
  const SymlinkAnalyzer_1 = require("./SymlinkAnalyzer");
41
+ const AssetHandler_1 = require("./AssetHandler");
43
42
  const Utils_1 = require("./Utils");
44
43
  const PathConstants_1 = require("./PathConstants");
45
44
  exports.TARGET_ROOT_SCRIPT_RELATIVE_PATH_TEMPLATE_STRING = '{TARGET_ROOT_SCRIPT_RELATIVE_PATH}';
@@ -71,54 +70,31 @@ class PackageExtractor {
71
70
  */
72
71
  async extractAsync(options) {
73
72
  options = PackageExtractor._normalizeOptions(options);
74
- const { terminal, projectConfigurations, sourceRootFolder, targetRootFolder, mainProjectName, overwriteExisting, createArchiveFilePath, createArchiveOnly, dependencyConfigurations } = options;
75
- if (createArchiveOnly) {
76
- if (options.linkCreation !== 'script' && options.linkCreation !== 'none') {
77
- throw new Error('createArchiveOnly is only supported when linkCreation is "script" or "none"');
78
- }
79
- if (!createArchiveFilePath) {
80
- throw new Error('createArchiveOnly is only supported when createArchiveFilePath is specified');
81
- }
82
- }
83
- let archiver;
84
- let archiveFilePath;
85
- if (createArchiveFilePath) {
86
- if (path.extname(createArchiveFilePath) !== '.zip') {
87
- throw new Error('Only archives with the .zip file extension are currently supported.');
88
- }
89
- archiveFilePath = path.resolve(targetRootFolder, createArchiveFilePath);
90
- archiver = new ArchiveManager_1.ArchiveManager();
91
- }
92
- await node_core_library_1.FileSystem.ensureFolderAsync(targetRootFolder);
73
+ const { terminal, projectConfigurations, sourceRootFolder, targetRootFolder, mainProjectName, overwriteExisting, dependencyConfigurations } = options;
93
74
  terminal.writeLine(terminal_1.Colorize.cyan(`Extracting to target folder: ${targetRootFolder}`));
94
75
  terminal.writeLine(terminal_1.Colorize.cyan(`Main project for extraction: ${mainProjectName}`));
95
- try {
96
- const existingExtraction = (await node_core_library_1.FileSystem.readFolderItemNamesAsync(targetRootFolder)).length > 0;
97
- if (existingExtraction) {
98
- if (!overwriteExisting) {
99
- throw new Error('The extraction target folder is not empty. Overwrite must be explicitly requested');
100
- }
101
- else {
102
- terminal.writeLine('Deleting target folder contents...');
103
- terminal.writeLine('');
104
- await node_core_library_1.FileSystem.ensureEmptyFolderAsync(targetRootFolder);
105
- }
106
- }
107
- }
108
- catch (error) {
109
- if (!node_core_library_1.FileSystem.isFolderDoesNotExistError(error)) {
110
- throw error;
76
+ await node_core_library_1.FileSystem.ensureFolderAsync(targetRootFolder);
77
+ const existingExtraction = (await node_core_library_1.FileSystem.readFolderItemNamesAsync(targetRootFolder)).length > 0;
78
+ if (existingExtraction) {
79
+ if (!overwriteExisting) {
80
+ throw new Error('The extraction target folder is not empty. Overwrite must be explicitly requested');
111
81
  }
82
+ terminal.writeLine('Deleting target folder contents...');
83
+ terminal.writeLine('');
84
+ await node_core_library_1.FileSystem.ensureEmptyFolderAsync(targetRootFolder);
112
85
  }
113
86
  // Create a new state for each run
87
+ const symlinkAnalyzer = new SymlinkAnalyzer_1.SymlinkAnalyzer({
88
+ requiredSourceParentPath: sourceRootFolder
89
+ });
114
90
  const state = {
91
+ symlinkAnalyzer,
92
+ assetHandler: new AssetHandler_1.AssetHandler(Object.assign(Object.assign({}, options), { symlinkAnalyzer })),
115
93
  foldersToCopy: new Set(),
116
94
  packageJsonByPath: new Map(),
117
95
  projectConfigurationsByName: new Map(projectConfigurations.map((p) => [p.projectName, p])),
118
96
  projectConfigurationsByPath: new Map(projectConfigurations.map((p) => [p.projectFolder, p])),
119
- dependencyConfigurationsByName: new Map(),
120
- symlinkAnalyzer: new SymlinkAnalyzer_1.SymlinkAnalyzer({ requiredSourceParentPath: sourceRootFolder }),
121
- archiver
97
+ dependencyConfigurationsByName: new Map()
122
98
  };
123
99
  // set state dependencyConfigurationsByName
124
100
  for (const dependencyConfiguration of dependencyConfigurations || []) {
@@ -131,10 +107,7 @@ class PackageExtractor {
131
107
  existingDependencyConfigurations.push(dependencyConfiguration);
132
108
  }
133
109
  await this._performExtractionAsync(options, state);
134
- if (archiver && archiveFilePath) {
135
- terminal.writeLine(`Creating archive at "${archiveFilePath}"`);
136
- await archiver.createArchiveAsync(archiveFilePath);
137
- }
110
+ await state.assetHandler.finalizeAsync();
138
111
  }
139
112
  static _normalizeOptions(options) {
140
113
  if (options.subspaces) {
@@ -159,9 +132,8 @@ class PackageExtractor {
159
132
  return normalizedOptions;
160
133
  }
161
134
  async _performExtractionAsync(options, state) {
162
- var _a;
163
- const { terminal, mainProjectName, sourceRootFolder, targetRootFolder, folderToCopy: additionalFolderToCopy, linkCreation, linkCreationScriptPath, createArchiveOnly } = options;
164
- const { projectConfigurationsByName, foldersToCopy, symlinkAnalyzer } = state;
135
+ const { terminal, mainProjectName, sourceRootFolder, targetRootFolder, folderToCopy: additionalFolderToCopy, linkCreation, createArchiveOnly } = options;
136
+ const { projectConfigurationsByName, foldersToCopy } = state;
165
137
  const mainProjectConfiguration = projectConfigurationsByName.get(mainProjectName);
166
138
  if (!mainProjectConfiguration) {
167
139
  throw new Error(`Main project "${mainProjectName}" was not found in the list of projects`);
@@ -198,38 +170,11 @@ class PackageExtractor {
198
170
  const additionalFolderExtractorOptions = Object.assign(Object.assign({}, options), { sourceRootFolder: additionalFolderPath, targetRootFolder });
199
171
  await this._extractFolderAsync(additionalFolderPath, additionalFolderExtractorOptions, state);
200
172
  }
201
- switch (linkCreation) {
202
- case 'script': {
203
- terminal.writeLine(`Creating ${PathConstants_1.createLinksScriptFilename}`);
204
- const createLinksSourceFilePath = `${PathConstants_1.scriptsFolderPath}/${PathConstants_1.createLinksScriptFilename}`;
205
- const createLinksTargetFilePath = linkCreationScriptPath
206
- ? path.resolve(targetRootFolder, linkCreationScriptPath)
207
- : `${targetRootFolder}/${PathConstants_1.createLinksScriptFilename}`;
208
- let createLinksScriptContent = await node_core_library_1.FileSystem.readFileAsync(createLinksSourceFilePath);
209
- createLinksScriptContent = createLinksScriptContent.replace(exports.TARGET_ROOT_SCRIPT_RELATIVE_PATH_TEMPLATE_STRING, node_core_library_1.Path.convertToSlashes(path.relative(path.dirname(createLinksTargetFilePath), targetRootFolder)));
210
- if (!createArchiveOnly) {
211
- await node_core_library_1.FileSystem.writeFileAsync(createLinksTargetFilePath, createLinksScriptContent, {
212
- ensureFolderExists: true
213
- });
214
- }
215
- await ((_a = state.archiver) === null || _a === void 0 ? void 0 : _a.addToArchiveAsync({
216
- fileData: createLinksScriptContent,
217
- archivePath: path.relative(targetRootFolder, createLinksTargetFilePath)
218
- }));
219
- break;
220
- }
221
- case 'default': {
222
- terminal.writeLine('Creating symlinks');
223
- const linksToCopy = symlinkAnalyzer.reportSymlinks();
224
- await node_core_library_1.Async.forEachAsync(linksToCopy, async (linkToCopy) => {
225
- await this._extractSymlinkAsync(linkToCopy, options, state);
226
- });
227
- await this._makeBinLinksAsync(options, state);
228
- break;
229
- }
230
- default: {
231
- break;
232
- }
173
+ if (linkCreation === 'default') {
174
+ await this._makeBinLinksAsync(options, state);
175
+ }
176
+ else if (linkCreation === 'script') {
177
+ await this._writeCreateLinksScriptAsync(options, state);
233
178
  }
234
179
  terminal.writeLine('Creating extractor-metadata.json');
235
180
  await this._writeExtractorMetadataAsync(options, state);
@@ -381,47 +326,18 @@ class PackageExtractor {
381
326
  }
382
327
  return allDependencyNames;
383
328
  }
384
- /**
385
- * Maps a file path from IExtractorOptions.sourceRootFolder to IExtractorOptions.targetRootFolder
386
- *
387
- * Example input: "C:\\MyRepo\\libraries\\my-lib"
388
- * Example output: "C:\\MyRepo\\common\\deploy\\libraries\\my-lib"
389
- */
390
- _remapPathForExtractorFolder(absolutePathInSourceFolder, options) {
391
- const { sourceRootFolder, targetRootFolder } = options;
392
- const relativePath = path.relative(sourceRootFolder, absolutePathInSourceFolder);
393
- if (relativePath.startsWith('..')) {
394
- throw new Error(`Source path "${absolutePathInSourceFolder}" is not under "${sourceRootFolder}"`);
395
- }
396
- const absolutePathInTargetFolder = path.join(targetRootFolder, relativePath);
397
- return absolutePathInTargetFolder;
398
- }
399
- /**
400
- * Maps a file path from IExtractorOptions.sourceRootFolder to relative path
401
- *
402
- * Example input: "C:\\MyRepo\\libraries\\my-lib"
403
- * Example output: "libraries/my-lib"
404
- */
405
- _remapPathForExtractorMetadata(absolutePathInSourceFolder, options) {
406
- const { sourceRootFolder } = options;
407
- const relativePath = path.relative(sourceRootFolder, absolutePathInSourceFolder);
408
- if (relativePath.startsWith('..')) {
409
- throw new Error(`Source path "${absolutePathInSourceFolder}" is not under "${sourceRootFolder}"`);
410
- }
411
- return node_core_library_1.Path.convertToSlashes(relativePath);
412
- }
413
329
  /**
414
330
  * Copy one package folder to the extractor target folder.
415
331
  */
416
332
  async _extractFolderAsync(sourceFolderPath, options, state) {
417
- const { includeNpmIgnoreFiles, targetRootFolder } = options;
418
- const { projectConfigurationsByPath, packageJsonByPath, dependencyConfigurationsByName, archiver } = state;
333
+ const { includeNpmIgnoreFiles } = options;
334
+ const { projectConfigurationsByPath, packageJsonByPath, dependencyConfigurationsByName, assetHandler } = state;
419
335
  let useNpmIgnoreFilter = false;
420
336
  const sourceFolderRealPath = await node_core_library_1.FileSystem.getRealPathAsync(sourceFolderPath);
421
337
  const sourceProjectConfiguration = projectConfigurationsByPath.get(sourceFolderRealPath);
422
338
  const packagesJson = packageJsonByPath.get(sourceFolderRealPath);
423
- // As this function will be used to copy folder for both project inside monorepo and third party dependencies insides node_modules
424
- // Third party dependencies won't have project configurations
339
+ // As this function will be used to copy folder for both project inside monorepo and third party
340
+ // dependencies insides node_modules. Third party dependencies won't have project configurations
425
341
  const isLocalProject = !!sourceProjectConfiguration;
426
342
  // Function to filter files inside local project or third party dependencies.
427
343
  const isFileExcluded = (filePath) => {
@@ -464,10 +380,9 @@ class PackageExtractor {
464
380
  // Only use the npmignore filter if the project configuration explicitly asks for it
465
381
  useNpmIgnoreFilter = true;
466
382
  }
467
- const targetFolderPath = this._remapPathForExtractorFolder(sourceFolderPath, options);
383
+ const targetFolderPath = (0, Utils_1.remapSourcePathForTargetFolder)(Object.assign(Object.assign({}, options), { sourcePath: sourceFolderPath }));
468
384
  if (useNpmIgnoreFilter) {
469
385
  const npmPackFiles = await PackageExtractor.getPackageIncludedFilesAsync(sourceFolderPath);
470
- const alreadyCopiedSourcePaths = new Set();
471
386
  await node_core_library_1.Async.forEachAsync(npmPackFiles, async (npmPackFile) => {
472
387
  // In issue https://github.com/microsoft/rushstack/issues/2121 we found that npm-packlist sometimes returns
473
388
  // duplicate file paths, for example:
@@ -479,31 +394,17 @@ class PackageExtractor {
479
394
  if (isFileExcluded(npmPackFile)) {
480
395
  return;
481
396
  }
482
- // We can detect the duplicates by comparing the path.resolve() result.
483
- const copySourcePath = path.resolve(sourceFolderPath, npmPackFile);
484
- if (alreadyCopiedSourcePaths.has(copySourcePath)) {
485
- return;
486
- }
487
- alreadyCopiedSourcePaths.add(copySourcePath);
488
- const copyDestinationPath = path.join(targetFolderPath, npmPackFile);
489
- const copySourcePathNode = await state.symlinkAnalyzer.analyzePathAsync({
490
- inputPath: copySourcePath
397
+ const sourceFilePath = path.resolve(sourceFolderPath, npmPackFile);
398
+ const { kind, linkStats: sourceFileStats } = await state.symlinkAnalyzer.analyzePathAsync({
399
+ inputPath: sourceFilePath
491
400
  });
492
- if (copySourcePathNode.kind !== 'link') {
493
- if (!options.createArchiveOnly) {
494
- await node_core_library_1.FileSystem.ensureFolderAsync(path.dirname(copyDestinationPath));
495
- // Use the fs.copyFile API instead of FileSystem.copyFileAsync() since copyFileAsync performs
496
- // a needless stat() call to determine if it's a file or folder, and we already know it's a file.
497
- await fs.promises.copyFile(copySourcePath, copyDestinationPath, fs.constants.COPYFILE_EXCL);
498
- }
499
- if (archiver) {
500
- const archivePath = path.relative(targetRootFolder, copyDestinationPath);
501
- await archiver.addToArchiveAsync({
502
- filePath: copySourcePath,
503
- archivePath,
504
- stats: copySourcePathNode.linkStats
505
- });
506
- }
401
+ if (kind === 'file') {
402
+ const targetFilePath = path.resolve(targetFolderPath, npmPackFile);
403
+ await assetHandler.includeAssetAsync({
404
+ sourceFilePath,
405
+ sourceFileStats,
406
+ targetFilePath
407
+ });
507
408
  }
508
409
  }, {
509
410
  concurrency: 10
@@ -553,22 +454,12 @@ class PackageExtractor {
553
454
  callback();
554
455
  return;
555
456
  }
556
- const targetPath = path.join(targetFolderPath, relativeSourcePath);
557
- if (!options.createArchiveOnly) {
558
- // Manually call fs.copyFile to avoid unnecessary stat calls.
559
- const targetParentPath = path.dirname(targetPath);
560
- await node_core_library_1.FileSystem.ensureFolderAsync(targetParentPath);
561
- await fs.promises.copyFile(sourcePath, targetPath, fs.constants.COPYFILE_EXCL);
562
- }
563
- // Add the file to the archive. Only need to add files since directories will be auto-created
564
- if (archiver) {
565
- const archivePath = path.relative(targetRootFolder, targetPath);
566
- await archiver.addToArchiveAsync({
567
- filePath: sourcePath,
568
- archivePath: archivePath,
569
- stats: sourcePathNode.linkStats
570
- });
571
- }
457
+ const targetFilePath = path.resolve(targetFolderPath, relativeSourcePath);
458
+ await assetHandler.includeAssetAsync({
459
+ sourceFilePath: sourcePath,
460
+ sourceFileStats: sourcePathNode.linkStats,
461
+ targetFilePath
462
+ });
572
463
  }
573
464
  else if (sourcePathNode.kind === 'folder') {
574
465
  const children = await node_core_library_1.FileSystem.readFolderItemNamesAsync(sourcePath);
@@ -582,58 +473,11 @@ class PackageExtractor {
582
473
  });
583
474
  }
584
475
  }
585
- /**
586
- * Create a symlink as described by the ILinkInfo object.
587
- */
588
- async _extractSymlinkAsync(originalLinkInfo, options, state) {
589
- var _a;
590
- const linkInfo = {
591
- kind: originalLinkInfo.kind,
592
- linkPath: this._remapPathForExtractorFolder(originalLinkInfo.linkPath, options),
593
- targetPath: this._remapPathForExtractorFolder(originalLinkInfo.targetPath, options)
594
- };
595
- const newLinkFolder = path.dirname(linkInfo.linkPath);
596
- await node_core_library_1.FileSystem.ensureFolderAsync(newLinkFolder);
597
- // Link to the relative path for symlinks
598
- const relativeTargetPath = path.relative(newLinkFolder, linkInfo.targetPath);
599
- // NOTE: This logic is based on NpmLinkManager._createSymlink()
600
- if (linkInfo.kind === 'fileLink') {
601
- // For files, we use a Windows "hard link", because creating a symbolic link requires
602
- // administrator permission. However hard links seem to cause build failures on Mac,
603
- // so for all other operating systems we use symbolic links for this case.
604
- if (process.platform === 'win32') {
605
- await node_core_library_1.FileSystem.createHardLinkAsync({
606
- linkTargetPath: relativeTargetPath,
607
- newLinkPath: linkInfo.linkPath
608
- });
609
- }
610
- else {
611
- await node_core_library_1.FileSystem.createSymbolicLinkFileAsync({
612
- linkTargetPath: relativeTargetPath,
613
- newLinkPath: linkInfo.linkPath
614
- });
615
- }
616
- }
617
- else {
618
- // Junctions are only supported on Windows. This will create a symbolic link on other platforms.
619
- await node_core_library_1.FileSystem.createSymbolicLinkJunctionAsync({
620
- linkTargetPath: relativeTargetPath,
621
- newLinkPath: linkInfo.linkPath
622
- });
623
- }
624
- // Since the created symlinks have the required relative paths, they can be added directly to
625
- // the archive.
626
- await ((_a = state.archiver) === null || _a === void 0 ? void 0 : _a.addToArchiveAsync({
627
- filePath: linkInfo.linkPath,
628
- archivePath: path.relative(options.targetRootFolder, linkInfo.linkPath)
629
- }));
630
- }
631
476
  /**
632
477
  * Write the common/deploy/deploy-metadata.json file.
633
478
  */
634
479
  async _writeExtractorMetadataAsync(options, state) {
635
- var _a;
636
- const { mainProjectName, targetRootFolder, linkCreation, linkCreationScriptPath } = options;
480
+ const { mainProjectName, sourceRootFolder, targetRootFolder, linkCreation, linkCreationScriptPath } = options;
637
481
  const { projectConfigurationsByPath } = state;
638
482
  const extractorMetadataFileName = 'extractor-metadata.json';
639
483
  const extractorMetadataFolderPath = linkCreation === 'script' && linkCreationScriptPath
@@ -643,51 +487,50 @@ class PackageExtractor {
643
487
  const extractorMetadataJson = {
644
488
  mainProjectName,
645
489
  projects: [],
646
- links: []
490
+ links: [],
491
+ files: []
647
492
  };
648
493
  for (const { projectFolder, projectName } of projectConfigurationsByPath.values()) {
649
494
  if (state.foldersToCopy.has(projectFolder)) {
650
495
  extractorMetadataJson.projects.push({
651
496
  projectName,
652
- path: this._remapPathForExtractorMetadata(projectFolder, options)
497
+ path: (0, Utils_1.remapPathForExtractorMetadata)(sourceRootFolder, projectFolder)
653
498
  });
654
499
  }
655
500
  }
656
501
  // Remap the links to be relative to target folder
657
- for (const absoluteLinkInfo of state.symlinkAnalyzer.reportSymlinks()) {
658
- const relativeInfo = {
659
- kind: absoluteLinkInfo.kind,
660
- linkPath: this._remapPathForExtractorMetadata(absoluteLinkInfo.linkPath, options),
661
- targetPath: this._remapPathForExtractorMetadata(absoluteLinkInfo.targetPath, options)
662
- };
663
- extractorMetadataJson.links.push(relativeInfo);
664
- }
665
- const extractorMetadataFileContent = JSON.stringify(extractorMetadataJson, undefined, 0);
666
- if (!options.createArchiveOnly) {
667
- await node_core_library_1.FileSystem.writeFileAsync(extractorMetadataFilePath, extractorMetadataFileContent, {
668
- ensureFolderExists: true
502
+ for (const { kind, linkPath, targetPath } of state.symlinkAnalyzer.reportSymlinks()) {
503
+ extractorMetadataJson.links.push({
504
+ kind,
505
+ linkPath: (0, Utils_1.remapPathForExtractorMetadata)(sourceRootFolder, linkPath),
506
+ targetPath: (0, Utils_1.remapPathForExtractorMetadata)(sourceRootFolder, targetPath)
669
507
  });
670
508
  }
671
- const archivePath = path.relative(targetRootFolder, extractorMetadataFilePath);
672
- await ((_a = state.archiver) === null || _a === void 0 ? void 0 : _a.addToArchiveAsync({ archivePath, fileData: extractorMetadataFileContent }));
509
+ for (const assetPath of state.assetHandler.assetPaths) {
510
+ extractorMetadataJson.files.push((0, Utils_1.remapPathForExtractorMetadata)(targetRootFolder, assetPath));
511
+ }
512
+ const extractorMetadataFileContent = JSON.stringify(extractorMetadataJson, undefined, 0);
513
+ await state.assetHandler.includeAssetAsync({
514
+ sourceFileContent: extractorMetadataFileContent,
515
+ targetFilePath: extractorMetadataFilePath
516
+ });
673
517
  }
674
518
  async _makeBinLinksAsync(options, state) {
675
519
  const { terminal } = options;
676
520
  const extractedProjectFolders = Array.from(state.projectConfigurationsByPath.keys()).filter((folderPath) => state.foldersToCopy.has(folderPath));
677
521
  await node_core_library_1.Async.forEachAsync(extractedProjectFolders, async (projectFolder) => {
678
- const extractedProjectFolder = this._remapPathForExtractorFolder(projectFolder, options);
522
+ const extractedProjectFolder = (0, Utils_1.remapSourcePathForTargetFolder)(Object.assign(Object.assign({}, options), { sourcePath: projectFolder }));
679
523
  const extractedProjectNodeModulesFolder = path.join(extractedProjectFolder, 'node_modules');
680
524
  const extractedProjectBinFolder = path.join(extractedProjectNodeModulesFolder, '.bin');
681
525
  const linkedBinPackageNames = await (0, link_bins_1.default)(extractedProjectNodeModulesFolder, extractedProjectBinFolder, {
682
526
  warn: (msg) => terminal.writeLine(terminal_1.Colorize.yellow(msg))
683
527
  });
684
- if (linkedBinPackageNames.length && state.archiver) {
528
+ if (linkedBinPackageNames.length) {
685
529
  const binFolderItems = await node_core_library_1.FileSystem.readFolderItemNamesAsync(extractedProjectBinFolder);
686
530
  for (const binFolderItem of binFolderItems) {
687
- const binFilePath = path.join(extractedProjectBinFolder, binFolderItem);
688
- await state.archiver.addToArchiveAsync({
689
- filePath: binFilePath,
690
- archivePath: path.relative(options.targetRootFolder, binFilePath)
531
+ const binFilePath = path.resolve(extractedProjectBinFolder, binFolderItem);
532
+ await state.assetHandler.includeAssetAsync({
533
+ targetFilePath: binFilePath
691
534
  });
692
535
  }
693
536
  }
@@ -695,6 +538,19 @@ class PackageExtractor {
695
538
  concurrency: 10
696
539
  });
697
540
  }
541
+ async _writeCreateLinksScriptAsync(options, state) {
542
+ const { terminal, targetRootFolder, linkCreationScriptPath } = options;
543
+ const { assetHandler } = state;
544
+ terminal.writeLine(`Creating ${PathConstants_1.createLinksScriptFilename}`);
545
+ const createLinksSourceFilePath = `${PathConstants_1.scriptsFolderPath}/${PathConstants_1.createLinksScriptFilename}`;
546
+ const createLinksTargetFilePath = path.resolve(targetRootFolder, linkCreationScriptPath || PathConstants_1.createLinksScriptFilename);
547
+ let createLinksScriptContent = await node_core_library_1.FileSystem.readFileAsync(createLinksSourceFilePath);
548
+ createLinksScriptContent = createLinksScriptContent.replace(exports.TARGET_ROOT_SCRIPT_RELATIVE_PATH_TEMPLATE_STRING, node_core_library_1.Path.convertToSlashes(path.relative(path.dirname(createLinksTargetFilePath), targetRootFolder)));
549
+ await assetHandler.includeAssetAsync({
550
+ sourceFileContent: createLinksScriptContent,
551
+ targetFilePath: createLinksTargetFilePath
552
+ });
553
+ }
698
554
  }
699
555
  exports.PackageExtractor = PackageExtractor;
700
556
  //# sourceMappingURL=PackageExtractor.js.map