@rushstack/package-extractor 0.12.0 → 0.12.2

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.
Files changed (84) hide show
  1. package/CHANGELOG.json +49 -0
  2. package/CHANGELOG.md +15 -1
  3. package/dist/scripts/create-links.js +17161 -1197
  4. package/dist/scripts/create-links.js.map +1 -1
  5. package/dist/tsdoc-metadata.json +1 -1
  6. package/lib-commonjs/ArchiveManager.js +64 -0
  7. package/lib-commonjs/ArchiveManager.js.map +1 -0
  8. package/lib-commonjs/AssetHandler.js +171 -0
  9. package/lib-commonjs/AssetHandler.js.map +1 -0
  10. package/lib-commonjs/PackageExtractor.js +568 -0
  11. package/lib-commonjs/PackageExtractor.js.map +1 -0
  12. package/lib-commonjs/PathConstants.js +11 -0
  13. package/lib-commonjs/PathConstants.js.map +1 -0
  14. package/lib-commonjs/SymlinkAnalyzer.js +159 -0
  15. package/lib-commonjs/SymlinkAnalyzer.js.map +1 -0
  16. package/lib-commonjs/Utils.js +85 -0
  17. package/lib-commonjs/Utils.js.map +1 -0
  18. package/lib-commonjs/index.js +8 -0
  19. package/lib-commonjs/index.js.map +1 -0
  20. package/lib-commonjs/scripts/createLinks/cli/CreateLinksCommandLineParser.js +35 -0
  21. package/lib-commonjs/scripts/createLinks/cli/CreateLinksCommandLineParser.js.map +1 -0
  22. package/lib-commonjs/scripts/createLinks/cli/actions/CreateLinksAction.js +91 -0
  23. package/lib-commonjs/scripts/createLinks/cli/actions/CreateLinksAction.js.map +1 -0
  24. package/lib-commonjs/scripts/createLinks/cli/actions/RemoveLinksAction.js +38 -0
  25. package/lib-commonjs/scripts/createLinks/cli/actions/RemoveLinksAction.js.map +1 -0
  26. package/lib-commonjs/scripts/createLinks/start.js +10 -0
  27. package/lib-commonjs/scripts/createLinks/start.js.map +1 -0
  28. package/lib-commonjs/scripts/createLinks/utilities/CreateLinksUtilities.js +14 -0
  29. package/lib-commonjs/scripts/createLinks/utilities/CreateLinksUtilities.js.map +1 -0
  30. package/lib-commonjs/scripts/createLinks/utilities/constants.js +44 -0
  31. package/lib-commonjs/scripts/createLinks/utilities/constants.js.map +1 -0
  32. package/lib-dts/ArchiveManager.d.ts +13 -0
  33. package/lib-dts/ArchiveManager.d.ts.map +1 -0
  34. package/lib-dts/AssetHandler.d.ts +52 -0
  35. package/lib-dts/AssetHandler.d.ts.map +1 -0
  36. package/lib-dts/PackageExtractor.d.ts +280 -0
  37. package/lib-dts/PackageExtractor.d.ts.map +1 -0
  38. package/lib-dts/PathConstants.d.ts +4 -0
  39. package/lib-dts/PathConstants.d.ts.map +1 -0
  40. package/lib-dts/SymlinkAnalyzer.d.ts +73 -0
  41. package/lib-dts/SymlinkAnalyzer.d.ts.map +1 -0
  42. package/lib-dts/Utils.d.ts +30 -0
  43. package/lib-dts/Utils.d.ts.map +1 -0
  44. package/lib-dts/index.d.ts +3 -0
  45. package/lib-dts/index.d.ts.map +1 -0
  46. package/lib-dts/scripts/createLinks/cli/CreateLinksCommandLineParser.d.ts +8 -0
  47. package/lib-dts/scripts/createLinks/cli/CreateLinksCommandLineParser.d.ts.map +1 -0
  48. package/lib-dts/scripts/createLinks/cli/actions/CreateLinksAction.d.ts +10 -0
  49. package/lib-dts/scripts/createLinks/cli/actions/CreateLinksAction.d.ts.map +1 -0
  50. package/lib-dts/scripts/createLinks/cli/actions/RemoveLinksAction.d.ts +10 -0
  51. package/lib-dts/scripts/createLinks/cli/actions/RemoveLinksAction.d.ts.map +1 -0
  52. package/lib-dts/scripts/createLinks/start.d.ts +2 -0
  53. package/lib-dts/scripts/createLinks/start.d.ts.map +1 -0
  54. package/lib-dts/scripts/createLinks/utilities/CreateLinksUtilities.d.ts +3 -0
  55. package/lib-dts/scripts/createLinks/utilities/CreateLinksUtilities.d.ts.map +1 -0
  56. package/lib-dts/scripts/createLinks/utilities/constants.d.ts +34 -0
  57. package/lib-dts/scripts/createLinks/utilities/constants.d.ts.map +1 -0
  58. package/lib-esm/ArchiveManager.js +57 -0
  59. package/lib-esm/ArchiveManager.js.map +1 -0
  60. package/lib-esm/AssetHandler.js +164 -0
  61. package/lib-esm/AssetHandler.js.map +1 -0
  62. package/lib-esm/PackageExtractor.js +528 -0
  63. package/lib-esm/PackageExtractor.js.map +1 -0
  64. package/lib-esm/PathConstants.js +8 -0
  65. package/lib-esm/PathConstants.js.map +1 -0
  66. package/lib-esm/SymlinkAnalyzer.js +122 -0
  67. package/lib-esm/SymlinkAnalyzer.js.map +1 -0
  68. package/lib-esm/Utils.js +76 -0
  69. package/lib-esm/Utils.js.map +1 -0
  70. package/lib-esm/index.js +4 -0
  71. package/lib-esm/index.js.map +1 -0
  72. package/lib-esm/scripts/createLinks/cli/CreateLinksCommandLineParser.js +31 -0
  73. package/lib-esm/scripts/createLinks/cli/CreateLinksCommandLineParser.js.map +1 -0
  74. package/lib-esm/scripts/createLinks/cli/actions/CreateLinksAction.js +84 -0
  75. package/lib-esm/scripts/createLinks/cli/actions/CreateLinksAction.js.map +1 -0
  76. package/lib-esm/scripts/createLinks/cli/actions/RemoveLinksAction.js +30 -0
  77. package/lib-esm/scripts/createLinks/cli/actions/RemoveLinksAction.js.map +1 -0
  78. package/lib-esm/scripts/createLinks/start.js +8 -0
  79. package/lib-esm/scripts/createLinks/start.js.map +1 -0
  80. package/lib-esm/scripts/createLinks/utilities/CreateLinksUtilities.js +11 -0
  81. package/lib-esm/scripts/createLinks/utilities/CreateLinksUtilities.js.map +1 -0
  82. package/lib-esm/scripts/createLinks/utilities/constants.js +38 -0
  83. package/lib-esm/scripts/createLinks/utilities/constants.js.map +1 -0
  84. package/package.json +9 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageExtractor.js","sourceRoot":"","sources":["../src/PackageExtractor.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO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CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,yBAAyB,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAChG,CAAC;QACF,MAAM,YAAY,CAAC,iBAAiB,CAAC;YACnC,iBAAiB,EAAE,wBAAwB;YAC3C,cAAc,EAAE,yBAAyB;SAC1C,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport { Minimatch } from 'minimatch';\nimport semver from 'semver';\nimport npmPacklist from 'npm-packlist';\nimport ignore, { type Ignore } from 'ignore';\n\nimport {\n Async,\n AsyncQueue,\n Path,\n FileSystem,\n Import,\n JsonFile,\n type IPackageJson\n} from '@rushstack/node-core-library';\nimport { Colorize, type ITerminal } from '@rushstack/terminal';\n\nimport { SymlinkAnalyzer, type ILinkInfo, type PathNode } from './SymlinkAnalyzer';\nimport { AssetHandler } from './AssetHandler';\nimport {\n matchesWithStar,\n remapSourcePathForTargetFolder,\n remapPathForExtractorMetadata,\n makeBinLinksAsync\n} from './Utils';\nimport {\n CREATE_LINKS_SCRIPT_FILENAME,\n EXTRACTOR_METADATA_FILENAME,\n SCRIPTS_FOLDER_PATH\n} from './PathConstants';\nimport { MAX_CONCURRENCY } from './scripts/createLinks/utilities/constants';\n\n// (@types/npm-packlist is missing this API)\ndeclare module 'npm-packlist' {\n export class Walker {\n public readonly result: string[];\n public constructor(opts: { path: string });\n public on(event: 'done', callback: (result: string[]) => void): Walker;\n public on(event: 'error', callback: (error: Error) => void): Walker;\n public start(): void;\n }\n}\n\nexport const TARGET_ROOT_SCRIPT_RELATIVE_PATH_TEMPLATE_STRING: '{TARGET_ROOT_SCRIPT_RELATIVE_PATH}' =\n '{TARGET_ROOT_SCRIPT_RELATIVE_PATH}';\n\n/**\n * Part of the extractor-matadata.json file format. Represents an extracted project.\n *\n * @public\n */\nexport interface IProjectInfoJson {\n /**\n * The name of the project as specified in its package.json file.\n */\n projectName: string;\n /**\n * This path is relative to the root of the extractor output folder\n */\n path: string;\n}\n\n/**\n * The extractor-metadata.json file format.\n *\n * @public\n */\nexport interface IExtractorMetadataJson {\n /**\n * The name of the main project the extraction was performed for.\n */\n mainProjectName: string;\n /**\n * A list of all projects that were extracted.\n */\n projects: IProjectInfoJson[];\n /**\n * A list of all links that are part of the extracted project.\n */\n links: ILinkInfo[];\n /**\n * A list of all files that are part of the extracted project.\n */\n files: string[];\n}\n\n/**\n * The extractor subspace configurations\n *\n * @public\n */\nexport interface IExtractorSubspace {\n /**\n * The subspace name\n */\n subspaceName: string;\n /**\n * The folder where the PNPM \"node_modules\" folder is located. This is used to resolve packages linked\n * to the PNPM virtual store.\n */\n pnpmInstallFolder?: string;\n /**\n * The pnpmfile configuration if using PNPM, otherwise undefined. The configuration will be used to\n * transform the package.json prior to extraction.\n */\n transformPackageJson?: (packageJson: IPackageJson) => IPackageJson;\n}\n\ninterface IExtractorState {\n foldersToCopy: Set<string>;\n packageJsonByPath: Map<string, IPackageJson>;\n projectConfigurationsByPath: Map<string, IExtractorProjectConfiguration>;\n projectConfigurationsByName: Map<string, IExtractorProjectConfiguration>;\n dependencyConfigurationsByName: Map<string, IExtractorDependencyConfiguration[]>;\n symlinkAnalyzer: SymlinkAnalyzer;\n assetHandler: AssetHandler;\n}\n\n/**\n * The extractor configuration for individual projects.\n *\n * @public\n */\nexport interface IExtractorProjectConfiguration {\n /**\n * The name of the project.\n */\n projectName: string;\n /**\n * The absolute path to the project.\n */\n projectFolder: string;\n /**\n * A list of glob patterns to include when extracting this project. If a path is\n * matched by both \"patternsToInclude\" and \"patternsToExclude\", the path will be\n * excluded. If undefined, all paths will be included.\n */\n patternsToInclude?: string[];\n /**\n * A list of glob patterns to exclude when extracting this project. If a path is\n * matched by both \"patternsToInclude\" and \"patternsToExclude\", the path will be\n * excluded. If undefined, no paths will be excluded.\n */\n patternsToExclude?: string[];\n /**\n * The names of additional projects to include when extracting this project.\n */\n additionalProjectsToInclude?: string[];\n /**\n * The names of additional dependencies to include when extracting this project.\n */\n additionalDependenciesToInclude?: string[];\n /**\n * The names of additional dependencies to exclude when extracting this project.\n */\n dependenciesToExclude?: string[];\n}\n\n/**\n * The extractor configuration for individual dependencies.\n *\n * @public\n */\nexport interface IExtractorDependencyConfiguration {\n /**\n * The name of dependency\n */\n dependencyName: string;\n /**\n * The semver version range of dependency\n */\n dependencyVersionRange: string;\n /**\n * A list of glob patterns to exclude when extracting this dependency. If a path is\n * matched by both \"patternsToInclude\" and \"patternsToExclude\", the path will be\n * excluded. If undefined, no paths will be excluded.\n */\n patternsToExclude?: string[];\n /**\n * A list of glob patterns to include when extracting this dependency. If a path is\n * matched by both \"patternsToInclude\" and \"patternsToExclude\", the path will be\n * excluded. If undefined, all paths will be included.\n */\n patternsToInclude?: string[];\n}\n\n/**\n * The mode to use for link creation.\n *\n * @public\n */\nexport type LinkCreationMode = 'default' | 'script' | 'none';\n\n/**\n * Options that can be provided to the extractor.\n *\n * @public\n */\nexport interface IExtractorOptions {\n /**\n * A terminal to log extraction progress.\n */\n terminal: ITerminal;\n\n /**\n * The main project to include in the extraction operation.\n */\n mainProjectName: string;\n\n /**\n * The source folder that copying originates from. Generally it is the repo root folder.\n */\n sourceRootFolder: string;\n\n /**\n * The target folder for the extraction.\n */\n targetRootFolder: string;\n\n /**\n * Whether to overwrite the target folder if it already exists.\n */\n overwriteExisting: boolean;\n\n /**\n * The desired path to be used when archiving the target folder. Supported file extensions: .zip.\n */\n createArchiveFilePath?: string;\n\n /**\n * Whether to skip copying files to the extraction target directory, and only create an extraction\n * archive. This is only supported when {@link IExtractorOptions.linkCreation} is 'script' or 'none'.\n */\n createArchiveOnly?: boolean;\n\n /**\n * The pnpmfile configuration if using PNPM, otherwise `undefined`. The configuration will be used to\n * transform the package.json prior to extraction.\n *\n * @remarks\n * When Rush subspaces are enabled, this setting applies to `default` subspace only. To configure\n * each subspace, use the {@link IExtractorOptions.subspaces} array instead. The two approaches\n * cannot be combined.\n */\n transformPackageJson?: (packageJson: IPackageJson) => IPackageJson;\n\n /**\n * If dependencies from the \"devDependencies\" package.json field should be included in the extraction.\n */\n includeDevDependencies?: boolean;\n\n /**\n * If files ignored by the .npmignore file should be included in the extraction.\n */\n includeNpmIgnoreFiles?: boolean;\n\n /**\n * The folder where the PNPM \"node_modules\" folder is located. This is used to resolve packages linked\n * to the PNPM virtual store.\n *\n * @remarks\n * When Rush subspaces are enabled, this setting applies to `default` subspace only. To configure\n * each subspace, use the {@link IExtractorOptions.subspaces} array instead. The two approaches\n * cannot be combined.\n */\n pnpmInstallFolder?: string;\n\n /**\n * The link creation mode to use.\n * \"default\": Create the links while copying the files; this is the default behavior. Use this setting\n * if your file copy tool can handle links correctly.\n * \"script\": A Node.js script called create-links.js will be written to the target folder. Use this setting\n * to create links on the server machine, after the files have been uploaded.\n * \"none\": Do nothing; some other tool may create the links later, based on the extractor-metadata.json file.\n */\n linkCreation?: LinkCreationMode;\n\n /**\n * The path to the generated link creation script. This is only used when {@link IExtractorOptions.linkCreation}\n * is 'script'.\n */\n linkCreationScriptPath?: string;\n\n /**\n * An additional folder containing files which will be copied into the root of the extraction.\n */\n folderToCopy?: string;\n\n /**\n * Configurations for individual projects, keyed by the project path relative to the sourceRootFolder.\n */\n projectConfigurations: IExtractorProjectConfiguration[];\n\n /**\n * Configurations for individual dependencies.\n */\n dependencyConfigurations?: IExtractorDependencyConfiguration[];\n\n /**\n * When using Rush subspaces, this setting can be used to provide configuration information for each\n * individual subspace.\n *\n * @remarks\n * To avoid confusion, if this setting is used, then the {@link IExtractorOptions.transformPackageJson} and\n * {@link IExtractorOptions.pnpmInstallFolder} settings must not be used.\n */\n subspaces?: IExtractorSubspace[];\n}\n\n/**\n * Manages the business logic for the \"rush deploy\" command.\n *\n * @public\n */\nexport class PackageExtractor {\n /**\n * Get a list of files that would be included in a package created from the provided package root path.\n *\n * @beta\n */\n public static async getPackageIncludedFilesAsync(packageRootPath: string): Promise<string[]> {\n // Use npm-packlist to filter the files. Using the Walker class (instead of the default API) ensures\n // that \"bundledDependencies\" are not included.\n const walkerPromise: Promise<string[]> = new Promise<string[]>(\n (resolve: (result: string[]) => void, reject: (error: Error) => void) => {\n const walker: npmPacklist.Walker = new npmPacklist.Walker({\n path: packageRootPath\n });\n walker.on('done', resolve).on('error', reject).start();\n }\n );\n const npmPackFiles: string[] = await walkerPromise;\n return npmPackFiles;\n }\n\n /**\n * Extract a package using the provided options\n */\n public async extractAsync(options: IExtractorOptions): Promise<void> {\n options = PackageExtractor._normalizeOptions(options);\n const {\n terminal,\n projectConfigurations,\n sourceRootFolder,\n targetRootFolder,\n mainProjectName,\n overwriteExisting,\n dependencyConfigurations,\n linkCreation\n } = options;\n\n terminal.writeLine(Colorize.cyan(`Extracting to target folder: ${targetRootFolder}`));\n terminal.writeLine(Colorize.cyan(`Main project for extraction: ${mainProjectName}`));\n\n await FileSystem.ensureFolderAsync(targetRootFolder);\n const existingExtraction: boolean =\n (await FileSystem.readFolderItemNamesAsync(targetRootFolder)).length > 0;\n if (existingExtraction) {\n if (!overwriteExisting) {\n throw new Error('The extraction target folder is not empty. Overwrite must be explicitly requested');\n }\n terminal.writeLine('Deleting target folder contents...');\n terminal.writeLine('');\n await FileSystem.ensureEmptyFolderAsync(targetRootFolder);\n }\n\n // Create a new state for each run\n const symlinkAnalyzer: SymlinkAnalyzer = new SymlinkAnalyzer({\n requiredSourceParentPath: sourceRootFolder\n });\n const state: IExtractorState = {\n symlinkAnalyzer,\n assetHandler: new AssetHandler({ ...options, symlinkAnalyzer }),\n foldersToCopy: new Set(),\n packageJsonByPath: new Map(),\n projectConfigurationsByName: new Map(projectConfigurations.map((p) => [p.projectName, p])),\n projectConfigurationsByPath: new Map(projectConfigurations.map((p) => [p.projectFolder, p])),\n dependencyConfigurationsByName: new Map()\n };\n\n // set state dependencyConfigurationsByName\n for (const dependencyConfiguration of dependencyConfigurations || []) {\n const { dependencyName } = dependencyConfiguration;\n let existingDependencyConfigurations: IExtractorDependencyConfiguration[] | undefined =\n state.dependencyConfigurationsByName.get(dependencyName);\n if (!existingDependencyConfigurations) {\n existingDependencyConfigurations = [];\n state.dependencyConfigurationsByName.set(dependencyName, existingDependencyConfigurations);\n }\n existingDependencyConfigurations.push(dependencyConfiguration);\n }\n\n await this._performExtractionAsync(options, state);\n await state.assetHandler.finalizeAsync({\n onAfterExtractSymlinksAsync: async () => {\n // We need the symlinks to be created before attempting to create the bin links, since it requires\n // the node_modules folder to be realized. While we're here, we may as well perform some specific\n // link creation tasks and write the extractor-metadata.json file before the asset handler finalizes.\n if (linkCreation === 'default') {\n await this._makeBinLinksAsync(options, state);\n } else if (linkCreation === 'script') {\n await this._writeCreateLinksScriptAsync(options, state);\n }\n\n terminal.writeLine('Creating extractor-metadata.json');\n await this._writeExtractorMetadataAsync(options, state);\n }\n });\n }\n\n private static _normalizeOptions(options: IExtractorOptions): IExtractorOptions {\n if (options.subspaces) {\n if (options.pnpmInstallFolder !== undefined) {\n throw new Error(\n 'IExtractorOptions.pnpmInstallFolder cannot be combined with IExtractorOptions.subspaces'\n );\n }\n if (options.transformPackageJson !== undefined) {\n throw new Error(\n 'IExtractorOptions.transformPackageJson cannot be combined with IExtractorOptions.subspaces'\n );\n }\n return options;\n }\n\n const normalizedOptions: IExtractorOptions = { ...options };\n delete normalizedOptions.pnpmInstallFolder;\n delete normalizedOptions.transformPackageJson;\n\n normalizedOptions.subspaces = [\n {\n subspaceName: 'default',\n pnpmInstallFolder: options.pnpmInstallFolder,\n transformPackageJson: options.transformPackageJson\n }\n ];\n\n return normalizedOptions;\n }\n\n private async _performExtractionAsync(options: IExtractorOptions, state: IExtractorState): Promise<void> {\n const {\n terminal,\n mainProjectName,\n sourceRootFolder,\n targetRootFolder,\n folderToCopy: additionalFolderToCopy,\n createArchiveOnly\n } = options;\n const { projectConfigurationsByName, foldersToCopy } = state;\n\n const mainProjectConfiguration: IExtractorProjectConfiguration | undefined =\n projectConfigurationsByName.get(mainProjectName);\n if (!mainProjectConfiguration) {\n throw new Error(`Main project \"${mainProjectName}\" was not found in the list of projects`);\n }\n\n // Calculate the set with additionalProjectsToInclude\n const includedProjectsSet: Set<IExtractorProjectConfiguration> = new Set([mainProjectConfiguration]);\n for (const { additionalProjectsToInclude } of includedProjectsSet) {\n if (additionalProjectsToInclude) {\n for (const additionalProjectNameToInclude of additionalProjectsToInclude) {\n const additionalProjectToInclude: IExtractorProjectConfiguration | undefined =\n projectConfigurationsByName.get(additionalProjectNameToInclude);\n if (!additionalProjectToInclude) {\n throw new Error(\n `Project \"${additionalProjectNameToInclude}\" was not found in the list of projects.`\n );\n }\n includedProjectsSet.add(additionalProjectToInclude);\n }\n }\n }\n\n for (const { projectName, projectFolder } of includedProjectsSet) {\n terminal.writeLine(Colorize.cyan(`Analyzing project: ${projectName}`));\n await this._collectFoldersAsync(projectFolder, options, state);\n }\n\n if (!createArchiveOnly) {\n terminal.writeLine(`Copying folders to target folder \"${targetRootFolder}\"`);\n }\n await Async.forEachAsync(\n foldersToCopy,\n async (folderToCopy: string) => {\n await this._extractFolderAsync(folderToCopy, options, state);\n },\n {\n concurrency: MAX_CONCURRENCY\n }\n );\n\n if (additionalFolderToCopy) {\n // Copy the additional folder directly into the root of the target folder by setting the sourceRootFolder\n // to the root of the folderToCopy\n const additionalFolderPath: string = path.resolve(sourceRootFolder, additionalFolderToCopy);\n const additionalFolderExtractorOptions: IExtractorOptions = {\n ...options,\n sourceRootFolder: additionalFolderPath,\n targetRootFolder\n };\n await this._extractFolderAsync(additionalFolderPath, additionalFolderExtractorOptions, state);\n }\n }\n\n /**\n * Recursively crawl the node_modules dependencies and collect the result in IExtractorState.foldersToCopy.\n */\n private async _collectFoldersAsync(\n packageJsonFolder: string,\n options: IExtractorOptions,\n state: IExtractorState\n ): Promise<void> {\n const { terminal, subspaces } = options;\n const { projectConfigurationsByPath } = state;\n\n const packageJsonFolderPathQueue: AsyncQueue<string> = new AsyncQueue([packageJsonFolder]);\n\n await Async.forEachAsync(\n packageJsonFolderPathQueue,\n async ([packageJsonFolderPath, callback]: [string, () => void]) => {\n const packageJsonRealFolderPath: string = await FileSystem.getRealPathAsync(packageJsonFolderPath);\n if (state.foldersToCopy.has(packageJsonRealFolderPath)) {\n // we've already seen this folder\n callback();\n return;\n }\n state.foldersToCopy.add(packageJsonRealFolderPath);\n\n const originalPackageJson: IPackageJson = await JsonFile.loadAsync(\n path.join(packageJsonRealFolderPath, 'package.json')\n );\n\n const targetSubspace: IExtractorSubspace | undefined = subspaces?.find(\n (subspace) =>\n subspace.pnpmInstallFolder && Path.isUnder(packageJsonFolderPath, subspace.pnpmInstallFolder)\n );\n\n // Transform packageJson using the provided transformer, if requested\n const packageJson: IPackageJson =\n targetSubspace?.transformPackageJson?.(originalPackageJson) ?? originalPackageJson;\n\n state.packageJsonByPath.set(packageJsonRealFolderPath, packageJson);\n // Union of keys from regular dependencies, peerDependencies, optionalDependencies\n // (and possibly devDependencies if includeDevDependencies=true)\n const dependencyNamesToProcess: Set<string> = new Set<string>();\n\n // Just the keys from optionalDependencies and peerDependencies\n const optionalDependencyNames: Set<string> = new Set<string>();\n\n for (const name of Object.keys(packageJson.dependencies || {})) {\n dependencyNamesToProcess.add(name);\n }\n for (const name of Object.keys(packageJson.peerDependencies || {})) {\n dependencyNamesToProcess.add(name);\n optionalDependencyNames.add(name); // consider peers optional, since they are so frequently broken\n }\n for (const name of Object.keys(packageJson.optionalDependencies || {})) {\n dependencyNamesToProcess.add(name);\n optionalDependencyNames.add(name);\n }\n\n // Check to see if this is a local project\n const projectConfiguration: IExtractorProjectConfiguration | undefined =\n projectConfigurationsByPath.get(packageJsonRealFolderPath);\n\n if (projectConfiguration) {\n if (options.includeDevDependencies) {\n for (const name of Object.keys(packageJson.devDependencies || {})) {\n dependencyNamesToProcess.add(name);\n }\n }\n\n this._applyDependencyFilters(\n terminal,\n dependencyNamesToProcess,\n projectConfiguration.additionalDependenciesToInclude,\n projectConfiguration.dependenciesToExclude\n );\n }\n\n for (const dependencyPackageName of dependencyNamesToProcess) {\n try {\n const dependencyPackageFolderPath: string = await Import.resolvePackageAsync({\n packageName: dependencyPackageName,\n baseFolderPath: packageJsonRealFolderPath,\n getRealPathAsync: async (filePath: string) => {\n try {\n return (await state.symlinkAnalyzer.analyzePathAsync({ inputPath: filePath })).nodePath;\n } catch (error: unknown) {\n if (FileSystem.isFileDoesNotExistError(error as Error)) {\n return filePath;\n }\n throw error;\n }\n }\n });\n packageJsonFolderPathQueue.push(dependencyPackageFolderPath);\n } catch (resolveErr) {\n if (optionalDependencyNames.has(dependencyPackageName)) {\n // Ignore missing optional dependency\n continue;\n }\n throw resolveErr;\n }\n }\n\n // Replicate the links to the virtual store. Note that if the package has not been hoisted by\n // PNPM, the package will not be resolvable from here.\n // Only apply this logic for packages that were actually installed under the common/temp folder.\n const realPnpmInstallFolder: string | undefined = targetSubspace?.pnpmInstallFolder;\n if (realPnpmInstallFolder && Path.isUnder(packageJsonFolderPath, realPnpmInstallFolder)) {\n try {\n // The PNPM virtual store links are created in this folder. We will resolve the current package\n // from that location and collect any additional links encountered along the way.\n // TODO: This can be configured via NPMRC. We should support that.\n const pnpmDotFolderPath: string = path.join(realPnpmInstallFolder, 'node_modules', '.pnpm');\n\n // TODO: Investigate how package aliases are handled by PNPM in this case. For example:\n //\n // \"dependencies\": {\n // \"alias-name\": \"npm:real-name@^1.2.3\"\n // }\n const dependencyPackageFolderPath: string = await Import.resolvePackageAsync({\n packageName: packageJson.name,\n baseFolderPath: pnpmDotFolderPath,\n getRealPathAsync: async (filePath: string) => {\n try {\n return (await state.symlinkAnalyzer.analyzePathAsync({ inputPath: filePath })).nodePath;\n } catch (error: unknown) {\n if (FileSystem.isFileDoesNotExistError(error as Error)) {\n return filePath;\n }\n throw error;\n }\n }\n });\n packageJsonFolderPathQueue.push(dependencyPackageFolderPath);\n } catch (resolveErr) {\n // The virtual store link isn't guaranteed to exist, so ignore if it's missing\n // NOTE: If you encounter this warning a lot, please report it to the Rush maintainers.\n // eslint-disable-next-line no-console\n console.log('Ignoring missing PNPM virtual store link for ' + packageJsonFolderPath);\n }\n }\n\n callback();\n },\n {\n concurrency: MAX_CONCURRENCY\n }\n );\n }\n\n private _applyDependencyFilters(\n terminal: ITerminal,\n allDependencyNames: Set<string>,\n additionalDependenciesToInclude: string[] = [],\n dependenciesToExclude: string[] = []\n ): Set<string> {\n // Track packages that got added/removed for reporting purposes\n const extraIncludedPackageNames: string[] = [];\n const extraExcludedPackageNames: string[] = [];\n\n for (const patternWithStar of dependenciesToExclude) {\n for (const dependency of allDependencyNames) {\n if (matchesWithStar(patternWithStar, dependency)) {\n if (allDependencyNames.delete(dependency)) {\n extraExcludedPackageNames.push(dependency);\n }\n }\n }\n }\n\n for (const dependencyToInclude of additionalDependenciesToInclude) {\n if (!allDependencyNames.has(dependencyToInclude)) {\n allDependencyNames.add(dependencyToInclude);\n extraIncludedPackageNames.push(dependencyToInclude);\n }\n }\n\n if (extraIncludedPackageNames.length > 0) {\n extraIncludedPackageNames.sort();\n terminal.writeLine(`Extra dependencies included by settings: ${extraIncludedPackageNames.join(', ')}`);\n }\n\n if (extraExcludedPackageNames.length > 0) {\n extraExcludedPackageNames.sort();\n terminal.writeLine(`Extra dependencies excluded by settings: ${extraExcludedPackageNames.join(', ')}`);\n }\n\n return allDependencyNames;\n }\n\n /**\n * Copy one package folder to the extractor target folder.\n */\n private async _extractFolderAsync(\n sourceFolderPath: string,\n options: IExtractorOptions,\n state: IExtractorState\n ): Promise<void> {\n const { includeNpmIgnoreFiles } = options;\n const { projectConfigurationsByPath, packageJsonByPath, dependencyConfigurationsByName, assetHandler } =\n state;\n let useNpmIgnoreFilter: boolean = false;\n\n const sourceFolderRealPath: string = await FileSystem.getRealPathAsync(sourceFolderPath);\n const sourceProjectConfiguration: IExtractorProjectConfiguration | undefined =\n projectConfigurationsByPath.get(sourceFolderRealPath);\n\n const packagesJson: IPackageJson | undefined = packageJsonByPath.get(sourceFolderRealPath);\n // As this function will be used to copy folder for both project inside monorepo and third party\n // dependencies insides node_modules. Third party dependencies won't have project configurations\n const isLocalProject: boolean = !!sourceProjectConfiguration;\n\n // Function to filter files inside local project or third party dependencies.\n const isFileExcluded = (filePath: string): boolean => {\n // Encapsulate exclude logic into a function, so it can be reused.\n const excludeFileByPatterns = (\n patternsToInclude: string[] | undefined,\n patternsToExclude: string[] | undefined\n ): boolean => {\n let includeFilters: Minimatch[] | undefined;\n let excludeFilters: Minimatch[] | undefined;\n if (patternsToInclude?.length) {\n includeFilters = patternsToInclude?.map((p) => new Minimatch(p, { dot: true }));\n }\n if (patternsToExclude?.length) {\n excludeFilters = patternsToExclude?.map((p) => new Minimatch(p, { dot: true }));\n }\n // If there are no filters, then we can't exclude anything.\n if (!includeFilters && !excludeFilters) {\n return false;\n }\n\n const isIncluded: boolean = !includeFilters || includeFilters.some((m) => m.match(filePath));\n\n // If the file is not included, then we don't need to check the excludeFilter. If it is included\n // and there is no exclude filter, then we know that the file is not excluded. If it is included\n // and there is an exclude filter, then we need to check for a match.\n return !isIncluded || !!excludeFilters?.some((m) => m.match(filePath));\n };\n\n if (isLocalProject) {\n return excludeFileByPatterns(\n sourceProjectConfiguration?.patternsToInclude,\n sourceProjectConfiguration?.patternsToExclude\n );\n } else {\n if (!packagesJson) {\n return false;\n }\n const dependenciesConfigurations: IExtractorDependencyConfiguration[] | undefined =\n dependencyConfigurationsByName.get(packagesJson.name);\n if (!dependenciesConfigurations) {\n return false;\n }\n const matchedDependenciesConfigurations: IExtractorDependencyConfiguration[] =\n dependenciesConfigurations.filter((d) =>\n semver.satisfies(packagesJson.version, d.dependencyVersionRange)\n );\n return matchedDependenciesConfigurations.some((d) =>\n excludeFileByPatterns(d.patternsToInclude, d.patternsToExclude)\n );\n }\n };\n\n if (sourceProjectConfiguration && !includeNpmIgnoreFiles) {\n // Only use the npmignore filter if the project configuration explicitly asks for it\n useNpmIgnoreFilter = true;\n }\n\n const targetFolderPath: string = remapSourcePathForTargetFolder({\n ...options,\n sourcePath: sourceFolderPath\n });\n if (useNpmIgnoreFilter) {\n const npmPackFiles: string[] = await PackageExtractor.getPackageIncludedFilesAsync(sourceFolderPath);\n await Async.forEachAsync(\n npmPackFiles,\n async (npmPackFile: string) => {\n // In issue https://github.com/microsoft/rushstack/issues/2121 we found that npm-packlist sometimes returns\n // duplicate file paths, for example:\n //\n // 'dist//index.js'\n // 'dist/index.js'\n //\n\n // Filter out files that are excluded by the project configuration or dependency configuration.\n if (isFileExcluded(npmPackFile)) {\n return;\n }\n\n const sourceFilePath: string = path.resolve(sourceFolderPath, npmPackFile);\n const { kind, linkStats: sourceFileStats } = await state.symlinkAnalyzer.analyzePathAsync({\n inputPath: sourceFilePath\n });\n if (kind === 'file') {\n const targetFilePath: string = path.resolve(targetFolderPath, npmPackFile);\n await assetHandler.includeAssetAsync({\n sourceFilePath,\n sourceFileStats,\n targetFilePath\n });\n }\n },\n {\n concurrency: MAX_CONCURRENCY\n }\n );\n } else {\n // use a simplistic \"ignore\" ruleset to filter the files\n const ignoreFilter: Ignore = ignore();\n ignoreFilter.add([\n // The top-level node_modules folder is always excluded\n '/node_modules',\n // Also exclude well-known folders that can contribute a lot of unnecessary files\n '**/.git',\n '**/.svn',\n '**/.hg',\n '**/.DS_Store'\n ]);\n\n // Do a breadth-first search of the source folder, copying each file to the target folder\n const queue: AsyncQueue<string> = new AsyncQueue([sourceFolderPath]);\n await Async.forEachAsync(\n queue,\n async ([sourcePath, callback]: [string, () => void]) => {\n const relativeSourcePath: string = path.relative(sourceFolderPath, sourcePath);\n if (relativeSourcePath !== '' && ignoreFilter.ignores(relativeSourcePath)) {\n callback();\n return;\n }\n\n const sourcePathNode: PathNode | undefined = await state.symlinkAnalyzer.analyzePathAsync({\n inputPath: sourcePath,\n // Treat all links to external paths as if they are files for this scenario. In the future, we may\n // want to explore the target of the external link to see if all files within the target are\n // excluded, and throw if they are not.\n shouldIgnoreExternalLink: (linkSourcePath: string) => {\n // Ignore the provided linkSourcePath since it may not be the first link in the chain. Instead,\n // we will consider only the relativeSourcePath, since that would be our entrypoint into the\n // link chain.\n return isFileExcluded(relativeSourcePath);\n }\n });\n\n if (sourcePathNode === undefined) {\n // The target was a symlink that is excluded. We don't need to do anything.\n callback();\n return;\n } else if (sourcePathNode.kind === 'file') {\n // Only ignore files and not folders to ensure that we traverse the contents of all folders. This is\n // done so that we can match against subfolder patterns, ex. \"src/subfolder/**/*\"\n if (relativeSourcePath !== '' && isFileExcluded(relativeSourcePath)) {\n callback();\n return;\n }\n\n const targetFilePath: string = path.resolve(targetFolderPath, relativeSourcePath);\n await assetHandler.includeAssetAsync({\n sourceFilePath: sourcePath,\n sourceFileStats: sourcePathNode.linkStats,\n targetFilePath\n });\n } else if (sourcePathNode.kind === 'folder') {\n const children: string[] = await FileSystem.readFolderItemNamesAsync(sourcePath);\n for (const child of children) {\n queue.push(path.join(sourcePath, child));\n }\n }\n\n callback();\n },\n {\n concurrency: MAX_CONCURRENCY\n }\n );\n }\n }\n\n /**\n * Write the common/deploy/deploy-metadata.json file.\n */\n private async _writeExtractorMetadataAsync(\n options: IExtractorOptions,\n state: IExtractorState\n ): Promise<void> {\n const { mainProjectName, sourceRootFolder, targetRootFolder, linkCreation, linkCreationScriptPath } =\n options;\n const { projectConfigurationsByPath } = state;\n\n const extractorMetadataFolderPath: string =\n linkCreation === 'script' && linkCreationScriptPath\n ? path.dirname(path.resolve(targetRootFolder, linkCreationScriptPath))\n : targetRootFolder;\n const extractorMetadataFilePath: string = path.join(\n extractorMetadataFolderPath,\n EXTRACTOR_METADATA_FILENAME\n );\n const extractorMetadataJson: IExtractorMetadataJson = {\n mainProjectName,\n projects: [],\n links: [],\n files: []\n };\n\n for (const { projectFolder, projectName } of projectConfigurationsByPath.values()) {\n if (state.foldersToCopy.has(projectFolder)) {\n extractorMetadataJson.projects.push({\n projectName,\n path: remapPathForExtractorMetadata(sourceRootFolder, projectFolder)\n });\n }\n }\n\n // Remap the links to be relative to target folder\n for (const { kind, linkPath, targetPath } of state.symlinkAnalyzer.reportSymlinks()) {\n extractorMetadataJson.links.push({\n kind,\n linkPath: remapPathForExtractorMetadata(sourceRootFolder, linkPath),\n targetPath: remapPathForExtractorMetadata(sourceRootFolder, targetPath)\n });\n }\n\n for (const assetPath of state.assetHandler.assetPaths) {\n extractorMetadataJson.files.push(remapPathForExtractorMetadata(targetRootFolder, assetPath));\n }\n\n const extractorMetadataFileContent: string = JSON.stringify(extractorMetadataJson, undefined, 0);\n await state.assetHandler.includeAssetAsync({\n sourceFileContent: extractorMetadataFileContent,\n targetFilePath: extractorMetadataFilePath\n });\n }\n\n private async _makeBinLinksAsync(options: IExtractorOptions, state: IExtractorState): Promise<void> {\n const { terminal } = options;\n\n const extractedProjectFolderPaths: string[] = [];\n for (const folderPath of state.projectConfigurationsByPath.keys()) {\n if (state.foldersToCopy.has(folderPath)) {\n extractedProjectFolderPaths.push(\n remapSourcePathForTargetFolder({ ...options, sourcePath: folderPath })\n );\n }\n }\n\n const binFilePaths: string[] = await makeBinLinksAsync(terminal, extractedProjectFolderPaths);\n await Async.forEachAsync(\n binFilePaths,\n (targetFilePath: string) => state.assetHandler.includeAssetAsync({ targetFilePath }),\n {\n concurrency: MAX_CONCURRENCY\n }\n );\n }\n\n private async _writeCreateLinksScriptAsync(\n options: IExtractorOptions,\n state: IExtractorState\n ): Promise<void> {\n const { terminal, targetRootFolder, linkCreationScriptPath } = options;\n const { assetHandler } = state;\n\n terminal.writeLine(`Creating ${CREATE_LINKS_SCRIPT_FILENAME}`);\n const createLinksSourceFilePath: string = `${SCRIPTS_FOLDER_PATH}/${CREATE_LINKS_SCRIPT_FILENAME}`;\n const createLinksTargetFilePath: string = path.resolve(\n targetRootFolder,\n linkCreationScriptPath || CREATE_LINKS_SCRIPT_FILENAME\n );\n let createLinksScriptContent: string = await FileSystem.readFileAsync(createLinksSourceFilePath);\n createLinksScriptContent = createLinksScriptContent.replace(\n TARGET_ROOT_SCRIPT_RELATIVE_PATH_TEMPLATE_STRING,\n Path.convertToSlashes(path.relative(path.dirname(createLinksTargetFilePath), targetRootFolder))\n );\n await assetHandler.includeAssetAsync({\n sourceFileContent: createLinksScriptContent,\n targetFilePath: createLinksTargetFilePath\n });\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { PackageJsonLookup } from '@rushstack/node-core-library';
4
+ export const CREATE_LINKS_SCRIPT_FILENAME = 'create-links.js';
5
+ export const EXTRACTOR_METADATA_FILENAME = 'extractor-metadata.json';
6
+ const packageExtractorFolderRootPath = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
7
+ export const SCRIPTS_FOLDER_PATH = `${packageExtractorFolderRootPath}/dist/scripts`;
8
+ //# sourceMappingURL=PathConstants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathConstants.js","sourceRoot":"","sources":["../src/PathConstants.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,CAAC,MAAM,4BAA4B,GAAsB,iBAAiB,CAAC;AAEjF,MAAM,CAAC,MAAM,2BAA2B,GAA8B,yBAAyB,CAAC;AAEhG,MAAM,8BAA8B,GAAW,iBAAiB,CAAC,QAAQ,CAAC,sBAAsB,CAAC,SAAS,CAAE,CAAC;AAC7G,MAAM,CAAC,MAAM,mBAAmB,GAAW,GAAG,8BAA8B,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { PackageJsonLookup } from '@rushstack/node-core-library';\n\nexport const CREATE_LINKS_SCRIPT_FILENAME: 'create-links.js' = 'create-links.js';\n\nexport const EXTRACTOR_METADATA_FILENAME: 'extractor-metadata.json' = 'extractor-metadata.json';\n\nconst packageExtractorFolderRootPath: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!;\nexport const SCRIPTS_FOLDER_PATH: string = `${packageExtractorFolderRootPath}/dist/scripts`;\n"]}
@@ -0,0 +1,122 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import * as path from 'node:path';
4
+ import { FileSystem, Sort } from '@rushstack/node-core-library';
5
+ export class SymlinkAnalyzer {
6
+ constructor(options = {}) {
7
+ // The directory tree discovered so far
8
+ this._nodesByPath = new Map();
9
+ // The symlinks that we encountered while building the directory tree
10
+ this._linkInfosByPath = new Map();
11
+ this._requiredSourceParentPath = options.requiredSourceParentPath;
12
+ }
13
+ async analyzePathAsync(options) {
14
+ const { inputPath, preserveLinks = false, shouldIgnoreExternalLink } = options;
15
+ // First, try to short-circuit the analysis if we've already analyzed this path
16
+ const resolvedPath = path.resolve(inputPath);
17
+ const existingNode = this._nodesByPath.get(resolvedPath);
18
+ if (existingNode) {
19
+ return existingNode;
20
+ }
21
+ // Postfix a '/' to the end of the path. This will get trimmed off later, but it
22
+ // ensures that the last path component is included in the loop below.
23
+ let targetPath = `${resolvedPath}${path.sep}`;
24
+ let targetPathIndex = -1;
25
+ let currentNode;
26
+ while ((targetPathIndex = targetPath.indexOf(path.sep, targetPathIndex + 1)) >= 0) {
27
+ if (targetPathIndex === 0) {
28
+ // Edge case for a Unix path like "/folder/file" --> [ "", "folder", "file" ]
29
+ continue;
30
+ }
31
+ const currentPath = targetPath.slice(0, targetPathIndex);
32
+ currentNode = this._nodesByPath.get(currentPath);
33
+ if (currentNode === undefined) {
34
+ const linkStats = await FileSystem.getLinkStatisticsAsync(currentPath);
35
+ if (linkStats.isSymbolicLink()) {
36
+ // Link target paths can be relative or absolute, so we need to resolve them
37
+ const linkTargetPath = await FileSystem.readLinkAsync(currentPath);
38
+ const resolvedLinkTargetPath = path.resolve(path.dirname(currentPath), linkTargetPath);
39
+ // Do a check to make sure that the link target path is not outside the source folder
40
+ if (this._requiredSourceParentPath) {
41
+ const relativeLinkTargetPath = path.relative(this._requiredSourceParentPath, resolvedLinkTargetPath);
42
+ if (relativeLinkTargetPath.startsWith('..')) {
43
+ // Symlinks that link outside of the source folder may be ignored. Check to see if we
44
+ // can ignore this one and if so, return undefined.
45
+ if (shouldIgnoreExternalLink === null || shouldIgnoreExternalLink === void 0 ? void 0 : shouldIgnoreExternalLink(currentPath)) {
46
+ return undefined;
47
+ }
48
+ throw new Error(`Symlink targets not under folder "${this._requiredSourceParentPath}": ` +
49
+ `${currentPath} -> ${resolvedLinkTargetPath}`);
50
+ }
51
+ }
52
+ currentNode = {
53
+ kind: 'link',
54
+ nodePath: currentPath,
55
+ linkStats,
56
+ linkTarget: resolvedLinkTargetPath
57
+ };
58
+ }
59
+ else if (linkStats.isDirectory()) {
60
+ currentNode = {
61
+ kind: 'folder',
62
+ nodePath: currentPath,
63
+ linkStats
64
+ };
65
+ }
66
+ else if (linkStats.isFile()) {
67
+ currentNode = {
68
+ kind: 'file',
69
+ nodePath: currentPath,
70
+ linkStats
71
+ };
72
+ }
73
+ else {
74
+ throw new Error('Unknown object type: ' + currentPath);
75
+ }
76
+ this._nodesByPath.set(currentPath, currentNode);
77
+ }
78
+ if (!preserveLinks) {
79
+ while ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.kind) === 'link') {
80
+ const targetNode = await this.analyzePathAsync({
81
+ inputPath: currentNode.linkTarget,
82
+ preserveLinks: true
83
+ });
84
+ // Have we created an ILinkInfo for this link yet?
85
+ if (!this._linkInfosByPath.has(currentNode.nodePath)) {
86
+ // Follow any symbolic links to determine whether the final target is a directory
87
+ const targetStats = await FileSystem.getStatisticsAsync(targetNode.nodePath);
88
+ const targetIsDirectory = targetStats.isDirectory();
89
+ const linkInfo = {
90
+ kind: targetIsDirectory ? 'folderLink' : 'fileLink',
91
+ linkPath: currentNode.nodePath,
92
+ targetPath: targetNode.nodePath
93
+ };
94
+ this._linkInfosByPath.set(currentNode.nodePath, linkInfo);
95
+ }
96
+ const nodeTargetPath = targetNode.nodePath;
97
+ const remainingPath = targetPath.slice(targetPathIndex);
98
+ targetPath = path.join(nodeTargetPath, remainingPath);
99
+ targetPathIndex = nodeTargetPath.length;
100
+ currentNode = targetNode;
101
+ }
102
+ }
103
+ if (targetPath.length === targetPathIndex + 1) {
104
+ // We've reached the end of the path
105
+ break;
106
+ }
107
+ }
108
+ if (!currentNode) {
109
+ throw new Error('Unable to analyze path: ' + inputPath);
110
+ }
111
+ return currentNode;
112
+ }
113
+ /**
114
+ * Returns a summary of all the symbolic links encountered by {@link SymlinkAnalyzer.analyzePathAsync}.
115
+ */
116
+ reportSymlinks() {
117
+ const list = [...this._linkInfosByPath.values()];
118
+ Sort.sortBy(list, (x) => x.linkPath);
119
+ return list;
120
+ }
121
+ }
122
+ //# sourceMappingURL=SymlinkAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SymlinkAnalyzer.js","sourceRoot":"","sources":["../src/SymlinkAnalyzer.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,UAAU,EAAwB,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAoEtF,MAAM,OAAO,eAAe;IAS1B,YAAmB,UAAmC,EAAE;QANxD,uCAAuC;QACtB,iBAAY,GAA0B,IAAI,GAAG,EAAoB,CAAC;QAEnF,qEAAqE;QACpD,qBAAgB,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAGvF,IAAI,CAAC,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IACpE,CAAC;IAQM,KAAK,CAAC,gBAAgB,CAAC,OAA4B;QACxD,MAAM,EAAE,SAAS,EAAE,aAAa,GAAG,KAAK,EAAE,wBAAwB,EAAE,GAAG,OAAO,CAAC;QAE/E,+EAA+E;QAC/E,MAAM,YAAY,GAAW,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAA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,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'node:path';\n\nimport { FileSystem, type FileSystemStats, Sort } from '@rushstack/node-core-library';\n\nexport interface IPathNodeBase {\n kind: 'file' | 'folder' | 'link';\n nodePath: string;\n linkStats: FileSystemStats;\n}\n\n/**\n * Represents a file object analyzed by {@link SymlinkAnalyzer}.\n */\nexport interface IFileNode extends IPathNodeBase {\n kind: 'file';\n}\n\n/**\n * Represents a folder object analyzed by {@link SymlinkAnalyzer}.\n */\nexport interface IFolderNode extends IPathNodeBase {\n kind: 'folder';\n}\n\n/**\n * Represents a symbolic link analyzed by {@link SymlinkAnalyzer}.\n */\nexport interface ILinkNode extends IPathNodeBase {\n kind: 'link';\n\n /**\n * The immediate target that the symlink resolves to.\n */\n linkTarget: string;\n}\n\nexport type PathNode = IFileNode | IFolderNode | ILinkNode;\n\n/**\n * Represents a symbolic link.\n *\n * @public\n */\nexport interface ILinkInfo {\n /**\n * The type of link that was encountered.\n */\n kind: 'fileLink' | 'folderLink';\n\n /**\n * The path to the link, relative to the root of the extractor output folder.\n */\n linkPath: string;\n\n /**\n * The target that the link points to.\n */\n targetPath: string;\n}\n\nexport interface ISymlinkAnalyzerOptions {\n requiredSourceParentPath?: string;\n}\n\nexport interface IAnalyzePathOptions {\n inputPath: string;\n preserveLinks?: boolean;\n shouldIgnoreExternalLink?: (path: string) => boolean;\n}\n\nexport class SymlinkAnalyzer {\n private readonly _requiredSourceParentPath: string | undefined;\n\n // The directory tree discovered so far\n private readonly _nodesByPath: Map<string, PathNode> = new Map<string, PathNode>();\n\n // The symlinks that we encountered while building the directory tree\n private readonly _linkInfosByPath: Map<string, ILinkInfo> = new Map<string, ILinkInfo>();\n\n public constructor(options: ISymlinkAnalyzerOptions = {}) {\n this._requiredSourceParentPath = options.requiredSourceParentPath;\n }\n\n public async analyzePathAsync(\n options: IAnalyzePathOptions & { shouldIgnoreExternalLink: (path: string) => boolean }\n ): Promise<PathNode | undefined>;\n public async analyzePathAsync(\n options: IAnalyzePathOptions & { shouldIgnoreExternalLink?: never }\n ): Promise<PathNode>;\n public async analyzePathAsync(options: IAnalyzePathOptions): Promise<PathNode | undefined> {\n const { inputPath, preserveLinks = false, shouldIgnoreExternalLink } = options;\n\n // First, try to short-circuit the analysis if we've already analyzed this path\n const resolvedPath: string = path.resolve(inputPath);\n const existingNode: PathNode | undefined = this._nodesByPath.get(resolvedPath);\n if (existingNode) {\n return existingNode;\n }\n\n // Postfix a '/' to the end of the path. This will get trimmed off later, but it\n // ensures that the last path component is included in the loop below.\n let targetPath: string = `${resolvedPath}${path.sep}`;\n let targetPathIndex: number = -1;\n let currentNode: PathNode | undefined;\n\n while ((targetPathIndex = targetPath.indexOf(path.sep, targetPathIndex + 1)) >= 0) {\n if (targetPathIndex === 0) {\n // Edge case for a Unix path like \"/folder/file\" --> [ \"\", \"folder\", \"file\" ]\n continue;\n }\n\n const currentPath: string = targetPath.slice(0, targetPathIndex);\n currentNode = this._nodesByPath.get(currentPath);\n if (currentNode === undefined) {\n const linkStats: FileSystemStats = await FileSystem.getLinkStatisticsAsync(currentPath);\n if (linkStats.isSymbolicLink()) {\n // Link target paths can be relative or absolute, so we need to resolve them\n const linkTargetPath: string = await FileSystem.readLinkAsync(currentPath);\n const resolvedLinkTargetPath: string = path.resolve(path.dirname(currentPath), linkTargetPath);\n\n // Do a check to make sure that the link target path is not outside the source folder\n if (this._requiredSourceParentPath) {\n const relativeLinkTargetPath: string = path.relative(\n this._requiredSourceParentPath,\n resolvedLinkTargetPath\n );\n if (relativeLinkTargetPath.startsWith('..')) {\n // Symlinks that link outside of the source folder may be ignored. Check to see if we\n // can ignore this one and if so, return undefined.\n if (shouldIgnoreExternalLink?.(currentPath)) {\n return undefined;\n }\n throw new Error(\n `Symlink targets not under folder \"${this._requiredSourceParentPath}\": ` +\n `${currentPath} -> ${resolvedLinkTargetPath}`\n );\n }\n }\n\n currentNode = {\n kind: 'link',\n nodePath: currentPath,\n linkStats,\n linkTarget: resolvedLinkTargetPath\n };\n } else if (linkStats.isDirectory()) {\n currentNode = {\n kind: 'folder',\n nodePath: currentPath,\n linkStats\n };\n } else if (linkStats.isFile()) {\n currentNode = {\n kind: 'file',\n nodePath: currentPath,\n linkStats\n };\n } else {\n throw new Error('Unknown object type: ' + currentPath);\n }\n this._nodesByPath.set(currentPath, currentNode);\n }\n\n if (!preserveLinks) {\n while (currentNode?.kind === 'link') {\n const targetNode: PathNode = await this.analyzePathAsync({\n inputPath: currentNode.linkTarget,\n preserveLinks: true\n });\n\n // Have we created an ILinkInfo for this link yet?\n if (!this._linkInfosByPath.has(currentNode.nodePath)) {\n // Follow any symbolic links to determine whether the final target is a directory\n const targetStats: FileSystemStats = await FileSystem.getStatisticsAsync(targetNode.nodePath);\n const targetIsDirectory: boolean = targetStats.isDirectory();\n const linkInfo: ILinkInfo = {\n kind: targetIsDirectory ? 'folderLink' : 'fileLink',\n linkPath: currentNode.nodePath,\n targetPath: targetNode.nodePath\n };\n this._linkInfosByPath.set(currentNode.nodePath, linkInfo);\n }\n\n const nodeTargetPath: string = targetNode.nodePath;\n const remainingPath: string = targetPath.slice(targetPathIndex);\n targetPath = path.join(nodeTargetPath, remainingPath);\n targetPathIndex = nodeTargetPath.length;\n currentNode = targetNode;\n }\n }\n\n if (targetPath.length === targetPathIndex + 1) {\n // We've reached the end of the path\n break;\n }\n }\n\n if (!currentNode) {\n throw new Error('Unable to analyze path: ' + inputPath);\n }\n\n return currentNode;\n }\n\n /**\n * Returns a summary of all the symbolic links encountered by {@link SymlinkAnalyzer.analyzePathAsync}.\n */\n public reportSymlinks(): ILinkInfo[] {\n const list: ILinkInfo[] = [...this._linkInfosByPath.values()];\n Sort.sortBy(list, (x) => x.linkPath);\n return list;\n }\n}\n"]}
@@ -0,0 +1,76 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import path from 'node:path';
4
+ import pnpmLinkBins from '@pnpm/link-bins';
5
+ import { Async, FileSystem, Path, Text } from '@rushstack/node-core-library';
6
+ import { Colorize } from '@rushstack/terminal';
7
+ import { MAX_CONCURRENCY } from './scripts/createLinks/utilities/constants';
8
+ export function matchesWithStar(patternWithStar, input) {
9
+ // Map "@types/*" --> "^\@types\/.*$"
10
+ const pattern = '^' +
11
+ patternWithStar
12
+ .split('*')
13
+ .map((x) => Text.escapeRegExp(x))
14
+ .join('.*') +
15
+ '$';
16
+ // eslint-disable-next-line @rushstack/security/no-unsafe-regexp
17
+ const regExp = new RegExp(pattern);
18
+ return regExp.test(input);
19
+ }
20
+ /**
21
+ * Maps a file path under the provided {@link IRemapPathForTargetFolder.sourceRootFolder} to the provided
22
+ * {@link IExtractorOptions.targetRootFolder}.
23
+ *
24
+ * Example input: "C:\\MyRepo\\libraries\\my-lib"
25
+ * Example output: "C:\\MyRepo\\common\\deploy\\libraries\\my-lib"
26
+ */
27
+ export function remapSourcePathForTargetFolder(options) {
28
+ const { sourcePath, sourceRootFolder, targetRootFolder } = options;
29
+ const relativePath = path.relative(sourceRootFolder, sourcePath);
30
+ if (relativePath.startsWith('..')) {
31
+ throw new Error(`Source path "${sourcePath}" is not under "${sourceRootFolder}"`);
32
+ }
33
+ const absolutePathInTargetFolder = path.join(targetRootFolder, relativePath);
34
+ return absolutePathInTargetFolder;
35
+ }
36
+ /**
37
+ * Maps a file path under the provided folder path to the expected path format for the extractor metadata.
38
+ *
39
+ * Example input: "C:\\MyRepo\\libraries\\my-lib"
40
+ * Example output: "common/deploy/libraries/my-lib"
41
+ */
42
+ export function remapPathForExtractorMetadata(folderPath, filePath) {
43
+ const relativePath = path.relative(folderPath, filePath);
44
+ if (relativePath.startsWith('..')) {
45
+ throw new Error(`Path "${filePath}" is not under "${folderPath}"`);
46
+ }
47
+ return Path.convertToSlashes(relativePath);
48
+ }
49
+ /**
50
+ * Creates the .bin files for the extracted projects and returns the paths to the created .bin files.
51
+ *
52
+ * @param terminal - The terminal to write to
53
+ * @param extractedProjectFolderPaths - The paths to the extracted projects
54
+ */
55
+ export async function makeBinLinksAsync(terminal, extractedProjectFolderPaths) {
56
+ const binFilePaths = [];
57
+ await Async.forEachAsync(extractedProjectFolderPaths, async (extractedProjectFolderPath) => {
58
+ const extractedProjectNodeModulesFolderPath = `${extractedProjectFolderPath}/node_modules`;
59
+ const extractedProjectBinFolderPath = `${extractedProjectNodeModulesFolderPath}/.bin`;
60
+ const linkedBinPackageNames = await pnpmLinkBins(extractedProjectNodeModulesFolderPath, extractedProjectBinFolderPath, {
61
+ warn: (msg) => terminal.writeLine(Colorize.yellow(msg))
62
+ });
63
+ if (linkedBinPackageNames.length) {
64
+ const binFolderItems = await FileSystem.readFolderItemNamesAsync(extractedProjectBinFolderPath);
65
+ for (const binFolderItem of binFolderItems) {
66
+ const binFilePath = `${extractedProjectBinFolderPath}/${binFolderItem}`;
67
+ terminal.writeVerboseLine(`Created .bin file: ${binFilePath}`);
68
+ binFilePaths.push(binFilePath);
69
+ }
70
+ }
71
+ }, {
72
+ concurrency: MAX_CONCURRENCY
73
+ });
74
+ return binFilePaths;
75
+ }
76
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAkB,MAAM,qBAAqB,CAAC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CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAmB,EACnB,2BAAqC;IAErC,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,KAAK,CAAC,YAAY,CACtB,2BAA2B,EAC3B,KAAK,EAAE,0BAAkC,EAAE,EAAE;QAC3C,MAAM,qCAAqC,GAAW,GAAG,0BAA0B,eAAe,CAAC;QACnG,MAAM,6BAA6B,GAAW,GAAG,qCAAqC,OAAO,CAAC;QAE9F,MAAM,qBAAqB,GAAa,MAAM,YAAY,CACxD,qCAAqC,EACrC,6BAA6B,EAC7B;YACE,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAChE,CACF,CAAC;QAEF,IAAI,qBAAqB,CAAC,MAAM,EAAE,CAAC;YACjC,MAAM,cAAc,GAAa,MAAM,UAAU,CAAC,wBAAwB,CACxE,6BAA6B,CAC9B,CAAC;YACF,KAAK,MAAM,aAAa,IAAI,cAAc,EAAE,CAAC;gBAC3C,MAAM,WAAW,GAAW,GAAG,6BAA6B,IAAI,aAAa,EAAE,CAAC;gBAChF,QAAQ,CAAC,gBAAgB,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC;gBAC/D,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC,EACD;QACE,WAAW,EAAE,eAAe;KAC7B,CACF,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport path from 'node:path';\n\nimport pnpmLinkBins from '@pnpm/link-bins';\n\nimport { Async, FileSystem, Path, Text } from '@rushstack/node-core-library';\nimport { Colorize, type ITerminal } from '@rushstack/terminal';\n\nimport { MAX_CONCURRENCY } from './scripts/createLinks/utilities/constants';\n\nexport function matchesWithStar(patternWithStar: string, input: string): boolean {\n // Map \"@types/*\" --> \"^\\@types\\/.*$\"\n const pattern: string =\n '^' +\n patternWithStar\n .split('*')\n .map((x) => Text.escapeRegExp(x))\n .join('.*') +\n '$';\n // eslint-disable-next-line @rushstack/security/no-unsafe-regexp\n const regExp: RegExp = new RegExp(pattern);\n return regExp.test(input);\n}\n\nexport interface IRemapPathForTargetFolder {\n sourcePath: string;\n sourceRootFolder: string;\n targetRootFolder: string;\n}\n\n/**\n * Maps a file path under the provided {@link IRemapPathForTargetFolder.sourceRootFolder} to the provided\n * {@link IExtractorOptions.targetRootFolder}.\n *\n * Example input: \"C:\\\\MyRepo\\\\libraries\\\\my-lib\"\n * Example output: \"C:\\\\MyRepo\\\\common\\\\deploy\\\\libraries\\\\my-lib\"\n */\nexport function remapSourcePathForTargetFolder(options: IRemapPathForTargetFolder): string {\n const { sourcePath, sourceRootFolder, targetRootFolder } = options;\n const relativePath: string = path.relative(sourceRootFolder, sourcePath);\n if (relativePath.startsWith('..')) {\n throw new Error(`Source path \"${sourcePath}\" is not under \"${sourceRootFolder}\"`);\n }\n const absolutePathInTargetFolder: string = path.join(targetRootFolder, relativePath);\n return absolutePathInTargetFolder;\n}\n\n/**\n * Maps a file path under the provided folder path to the expected path format for the extractor metadata.\n *\n * Example input: \"C:\\\\MyRepo\\\\libraries\\\\my-lib\"\n * Example output: \"common/deploy/libraries/my-lib\"\n */\nexport function remapPathForExtractorMetadata(folderPath: string, filePath: string): string {\n const relativePath: string = path.relative(folderPath, filePath);\n if (relativePath.startsWith('..')) {\n throw new Error(`Path \"${filePath}\" is not under \"${folderPath}\"`);\n }\n return Path.convertToSlashes(relativePath);\n}\n\n/**\n * Creates the .bin files for the extracted projects and returns the paths to the created .bin files.\n *\n * @param terminal - The terminal to write to\n * @param extractedProjectFolderPaths - The paths to the extracted projects\n */\nexport async function makeBinLinksAsync(\n terminal: ITerminal,\n extractedProjectFolderPaths: string[]\n): Promise<string[]> {\n const binFilePaths: string[] = [];\n await Async.forEachAsync(\n extractedProjectFolderPaths,\n async (extractedProjectFolderPath: string) => {\n const extractedProjectNodeModulesFolderPath: string = `${extractedProjectFolderPath}/node_modules`;\n const extractedProjectBinFolderPath: string = `${extractedProjectNodeModulesFolderPath}/.bin`;\n\n const linkedBinPackageNames: string[] = await pnpmLinkBins(\n extractedProjectNodeModulesFolderPath,\n extractedProjectBinFolderPath,\n {\n warn: (msg: string) => terminal.writeLine(Colorize.yellow(msg))\n }\n );\n\n if (linkedBinPackageNames.length) {\n const binFolderItems: string[] = await FileSystem.readFolderItemNamesAsync(\n extractedProjectBinFolderPath\n );\n for (const binFolderItem of binFolderItems) {\n const binFilePath: string = `${extractedProjectBinFolderPath}/${binFolderItem}`;\n terminal.writeVerboseLine(`Created .bin file: ${binFilePath}`);\n binFilePaths.push(binFilePath);\n }\n }\n },\n {\n concurrency: MAX_CONCURRENCY\n }\n );\n\n return binFilePaths;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ export { PackageExtractor } from './PackageExtractor';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EACL,gBAAgB,EAQjB,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nexport {\n PackageExtractor,\n type LinkCreationMode,\n type IExtractorOptions,\n type IExtractorProjectConfiguration,\n type IExtractorDependencyConfiguration,\n type IExtractorMetadataJson,\n type IProjectInfoJson,\n type IExtractorSubspace\n} from './PackageExtractor';\n\nexport type { ILinkInfo } from './SymlinkAnalyzer';\n"]}
@@ -0,0 +1,31 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { CommandLineParser } from '@rushstack/ts-command-line';
4
+ import { AlreadyReportedError } from '@rushstack/node-core-library';
5
+ import { CreateLinksAction } from './actions/CreateLinksAction';
6
+ import { RemoveLinksAction } from './actions/RemoveLinksAction';
7
+ export class CreateLinksCommandLineParser extends CommandLineParser {
8
+ constructor(terminal) {
9
+ super({
10
+ toolFilename: 'create-links',
11
+ toolDescription: 'Create or remove symlinks for the extracted packages'
12
+ });
13
+ this._terminal = terminal;
14
+ this.addAction(new CreateLinksAction(this._terminal));
15
+ this.addAction(new RemoveLinksAction(this._terminal));
16
+ }
17
+ async onExecuteAsync() {
18
+ process.exitCode = 1;
19
+ try {
20
+ await super.onExecuteAsync();
21
+ process.exitCode = 0;
22
+ }
23
+ catch (error) {
24
+ if (!(error instanceof AlreadyReportedError)) {
25
+ this._terminal.writeErrorLine();
26
+ this._terminal.writeErrorLine('ERROR: ' + error.message.trim());
27
+ }
28
+ }
29
+ }
30
+ }
31
+ //# sourceMappingURL=CreateLinksCommandLineParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateLinksCommandLineParser.js","sourceRoot":"","sources":["../../../../src/scripts/createLinks/cli/CreateLinksCommandLineParser.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,OAAO,4BAA6B,SAAQ,iBAAiB;IAGjE,YAAmB,QAAmB;QACpC,KAAK,CAAC;YACJ,YAAY,EAAE,cAAc;YAC5B,eAAe,EAAE,sDAAsD;SACxE,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,CAAC,SAAS,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACxD,CAAC;IAEkB,KAAK,CAAC,cAAc;QACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QAErB,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC;YAC7B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,oBAAoB,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;gBAChC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { CommandLineParser } from '@rushstack/ts-command-line';\nimport { AlreadyReportedError } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\n\nimport { CreateLinksAction } from './actions/CreateLinksAction';\nimport { RemoveLinksAction } from './actions/RemoveLinksAction';\n\nexport class CreateLinksCommandLineParser extends CommandLineParser {\n private readonly _terminal: ITerminal;\n\n public constructor(terminal: ITerminal) {\n super({\n toolFilename: 'create-links',\n toolDescription: 'Create or remove symlinks for the extracted packages'\n });\n\n this._terminal = terminal;\n\n this.addAction(new CreateLinksAction(this._terminal));\n this.addAction(new RemoveLinksAction(this._terminal));\n }\n\n protected override async onExecuteAsync(): Promise<void> {\n process.exitCode = 1;\n\n try {\n await super.onExecuteAsync();\n process.exitCode = 0;\n } catch (error) {\n if (!(error instanceof AlreadyReportedError)) {\n this._terminal.writeErrorLine();\n this._terminal.writeErrorLine('ERROR: ' + error.message.trim());\n }\n }\n }\n}\n"]}
@@ -0,0 +1,84 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import path from 'node:path';
4
+ import { Async, FileSystem, Path } from '@rushstack/node-core-library';
5
+ import { CommandLineAction } from '@rushstack/ts-command-line';
6
+ import { makeBinLinksAsync } from '../../../../Utils';
7
+ import { getExtractorMetadataAsync } from '../../utilities/CreateLinksUtilities';
8
+ import { TARGET_ROOT_FOLDER, REALIZE_FILES_PARAMETER_NAME, LINK_BINS_PARAMETER_NAME, MAX_CONCURRENCY } from '../../utilities/constants';
9
+ import { removeLinksAsync } from './RemoveLinksAction';
10
+ async function createLinksAsync(terminal, targetRootFolder, extractorMetadataObject) {
11
+ await Async.forEachAsync(extractorMetadataObject.links, async (linkInfo) => {
12
+ // Link to the relative path for symlinks
13
+ const newLinkPath = path.join(targetRootFolder, linkInfo.linkPath);
14
+ const linkTargetPath = path.join(targetRootFolder, linkInfo.targetPath);
15
+ // Make sure the containing folder exists
16
+ await FileSystem.ensureFolderAsync(path.dirname(newLinkPath));
17
+ // NOTE: This logic is based on NpmLinkManager._createSymlink()
18
+ if (linkInfo.kind === 'folderLink') {
19
+ terminal.writeVerboseLine(`Creating linked folder at path "${newLinkPath}"`);
20
+ await FileSystem.createSymbolicLinkJunctionAsync({ newLinkPath, linkTargetPath });
21
+ }
22
+ else if (linkInfo.kind === 'fileLink') {
23
+ // Use hardlinks for Windows and symlinks for other platforms since creating a symbolic link
24
+ // requires administrator permission on Windows. This may cause unexpected behaviour for consumers
25
+ // of the hardlinked files. If this becomes an issue, we may need to revisit this.
26
+ terminal.writeVerboseLine(`Creating linked file at path "${newLinkPath}"`);
27
+ if (process.platform === 'win32') {
28
+ await FileSystem.createHardLinkAsync({ newLinkPath, linkTargetPath });
29
+ }
30
+ else {
31
+ await FileSystem.createSymbolicLinkFileAsync({ newLinkPath, linkTargetPath });
32
+ }
33
+ }
34
+ }, { concurrency: MAX_CONCURRENCY });
35
+ }
36
+ async function realizeFilesAsync(terminal, targetRootFolder, extractorMetadataObject) {
37
+ await Async.forEachAsync(extractorMetadataObject.files, async (relativeFilePath) => {
38
+ const filePath = `${targetRootFolder}/${relativeFilePath}`;
39
+ const realFilePath = await FileSystem.getRealPathAsync(filePath);
40
+ if (!Path.isEqual(realFilePath, filePath)) {
41
+ // Delete the existing symlink and create a hardlink to the real file, since creating hardlinks
42
+ // is less overhead than copying the file.
43
+ terminal.writeVerboseLine(`Realizing file at path "${filePath}"`);
44
+ await FileSystem.deleteFileAsync(filePath);
45
+ await FileSystem.createHardLinkAsync({ newLinkPath: filePath, linkTargetPath: realFilePath });
46
+ }
47
+ }, { concurrency: MAX_CONCURRENCY });
48
+ }
49
+ export class CreateLinksAction extends CommandLineAction {
50
+ constructor(terminal) {
51
+ super({
52
+ actionName: 'create',
53
+ summary: 'Create symlinks for extraction',
54
+ documentation: 'This action creates symlinks for the extraction process.'
55
+ });
56
+ this._terminal = terminal;
57
+ this._realizeFilesParameter = this.defineFlagParameter({
58
+ parameterLongName: REALIZE_FILES_PARAMETER_NAME,
59
+ description: 'Realize files instead of creating symlinks'
60
+ });
61
+ this._linkBinsParameter = this.defineFlagParameter({
62
+ parameterLongName: LINK_BINS_PARAMETER_NAME,
63
+ description: 'Create the .bin files for extracted packages'
64
+ });
65
+ }
66
+ async onExecuteAsync() {
67
+ const extractorMetadataObject = await getExtractorMetadataAsync();
68
+ const realizeFiles = this._realizeFilesParameter.value;
69
+ const linkBins = this._linkBinsParameter.value;
70
+ this._terminal.writeLine(`Creating links for extraction at path "${TARGET_ROOT_FOLDER}"`);
71
+ await removeLinksAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);
72
+ await createLinksAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);
73
+ if (realizeFiles) {
74
+ this._terminal.writeLine(`Realizing files for extraction at path "${TARGET_ROOT_FOLDER}"`);
75
+ await realizeFilesAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);
76
+ }
77
+ if (linkBins) {
78
+ this._terminal.writeLine(`Linking bins for extraction at path "${TARGET_ROOT_FOLDER}"`);
79
+ const extractedProjectFolderPaths = extractorMetadataObject.projects.map((project) => path.join(TARGET_ROOT_FOLDER, project.path));
80
+ await makeBinLinksAsync(this._terminal, extractedProjectFolderPaths);
81
+ }
82
+ }
83
+ }
84
+ //# sourceMappingURL=CreateLinksAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CreateLinksAction.js","sourceRoot":"","sources":["../../../../../src/scripts/createLinks/cli/actions/CreateLinksAction.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAiC,MAAM,4BAA4B,CAAC;AAG9F,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,wBAAwB,EACxB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,KAAK,UAAU,gBAAgB,CAC7B,QAAmB,EACnB,gBAAwB,EACxB,uBAA+C;IAE/C,MAAM,KAAK,CAAC,YAAY,CACtB,uBAAuB,CAAC,KAAK,EAC7B,KAAK,EAAE,QAAQ,EAAE,EAAE;QACjB,yCAAyC;QACzC,MAAM,WAAW,GAAW,IAAI,CA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C,SAAS,CAAC,0CAA0C,kBAAkB,GAAG,CAAC,CAAC;QAC1F,MAAM,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;QACpF,MAAM,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;QAEpF,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,2CAA2C,kBAAkB,GAAG,CAAC,CAAC;YAC3F,MAAM,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;QACvF,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,wCAAwC,kBAAkB,GAAG,CAAC,CAAC;YACxF,MAAM,2BAA2B,GAAa,uBAAuB,CAAC,QAAQ,CAAC,GAAG,CAChF,CAAC,OAAyB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,CAC3E,CAAC;YACF,MAAM,iBAAiB,CAAC,IAAI,CAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport path from 'node:path';\n\nimport { Async, FileSystem, Path } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport { CommandLineAction, type CommandLineFlagParameter } from '@rushstack/ts-command-line';\n\nimport type { IExtractorMetadataJson, IProjectInfoJson } from '../../../../PackageExtractor';\nimport { makeBinLinksAsync } from '../../../../Utils';\nimport { getExtractorMetadataAsync } from '../../utilities/CreateLinksUtilities';\nimport {\n TARGET_ROOT_FOLDER,\n REALIZE_FILES_PARAMETER_NAME,\n LINK_BINS_PARAMETER_NAME,\n MAX_CONCURRENCY\n} from '../../utilities/constants';\nimport { removeLinksAsync } from './RemoveLinksAction';\n\nasync function createLinksAsync(\n terminal: ITerminal,\n targetRootFolder: string,\n extractorMetadataObject: IExtractorMetadataJson\n): Promise<void> {\n await Async.forEachAsync(\n extractorMetadataObject.links,\n async (linkInfo) => {\n // Link to the relative path for symlinks\n const newLinkPath: string = path.join(targetRootFolder, linkInfo.linkPath);\n const linkTargetPath: string = path.join(targetRootFolder, linkInfo.targetPath);\n\n // Make sure the containing folder exists\n await FileSystem.ensureFolderAsync(path.dirname(newLinkPath));\n\n // NOTE: This logic is based on NpmLinkManager._createSymlink()\n if (linkInfo.kind === 'folderLink') {\n terminal.writeVerboseLine(`Creating linked folder at path \"${newLinkPath}\"`);\n await FileSystem.createSymbolicLinkJunctionAsync({ newLinkPath, linkTargetPath });\n } else if (linkInfo.kind === 'fileLink') {\n // Use hardlinks for Windows and symlinks for other platforms since creating a symbolic link\n // requires administrator permission on Windows. This may cause unexpected behaviour for consumers\n // of the hardlinked files. If this becomes an issue, we may need to revisit this.\n terminal.writeVerboseLine(`Creating linked file at path \"${newLinkPath}\"`);\n if (process.platform === 'win32') {\n await FileSystem.createHardLinkAsync({ newLinkPath, linkTargetPath });\n } else {\n await FileSystem.createSymbolicLinkFileAsync({ newLinkPath, linkTargetPath });\n }\n }\n },\n { concurrency: MAX_CONCURRENCY }\n );\n}\n\nasync function realizeFilesAsync(\n terminal: ITerminal,\n targetRootFolder: string,\n extractorMetadataObject: IExtractorMetadataJson\n): Promise<void> {\n await Async.forEachAsync(\n extractorMetadataObject.files,\n async (relativeFilePath) => {\n const filePath: string = `${targetRootFolder}/${relativeFilePath}`;\n const realFilePath: string = await FileSystem.getRealPathAsync(filePath);\n if (!Path.isEqual(realFilePath, filePath)) {\n // Delete the existing symlink and create a hardlink to the real file, since creating hardlinks\n // is less overhead than copying the file.\n terminal.writeVerboseLine(`Realizing file at path \"${filePath}\"`);\n await FileSystem.deleteFileAsync(filePath);\n await FileSystem.createHardLinkAsync({ newLinkPath: filePath, linkTargetPath: realFilePath });\n }\n },\n { concurrency: MAX_CONCURRENCY }\n );\n}\n\nexport class CreateLinksAction extends CommandLineAction {\n private _terminal: ITerminal;\n private _realizeFilesParameter: CommandLineFlagParameter;\n private _linkBinsParameter: CommandLineFlagParameter;\n\n public constructor(terminal: ITerminal) {\n super({\n actionName: 'create',\n summary: 'Create symlinks for extraction',\n documentation: 'This action creates symlinks for the extraction process.'\n });\n\n this._terminal = terminal;\n\n this._realizeFilesParameter = this.defineFlagParameter({\n parameterLongName: REALIZE_FILES_PARAMETER_NAME,\n description: 'Realize files instead of creating symlinks'\n });\n\n this._linkBinsParameter = this.defineFlagParameter({\n parameterLongName: LINK_BINS_PARAMETER_NAME,\n description: 'Create the .bin files for extracted packages'\n });\n }\n\n protected override async onExecuteAsync(): Promise<void> {\n const extractorMetadataObject: IExtractorMetadataJson = await getExtractorMetadataAsync();\n const realizeFiles: boolean = this._realizeFilesParameter.value;\n const linkBins: boolean = this._linkBinsParameter.value;\n\n this._terminal.writeLine(`Creating links for extraction at path \"${TARGET_ROOT_FOLDER}\"`);\n await removeLinksAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);\n await createLinksAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);\n\n if (realizeFiles) {\n this._terminal.writeLine(`Realizing files for extraction at path \"${TARGET_ROOT_FOLDER}\"`);\n await realizeFilesAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);\n }\n\n if (linkBins) {\n this._terminal.writeLine(`Linking bins for extraction at path \"${TARGET_ROOT_FOLDER}\"`);\n const extractedProjectFolderPaths: string[] = extractorMetadataObject.projects.map(\n (project: IProjectInfoJson) => path.join(TARGET_ROOT_FOLDER, project.path)\n );\n await makeBinLinksAsync(this._terminal, extractedProjectFolderPaths);\n }\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import path from 'node:path';
4
+ import { Async, FileSystem } from '@rushstack/node-core-library';
5
+ import { CommandLineAction } from '@rushstack/ts-command-line';
6
+ import { getExtractorMetadataAsync } from '../../utilities/CreateLinksUtilities';
7
+ import { TARGET_ROOT_FOLDER, MAX_CONCURRENCY } from '../../utilities/constants';
8
+ export async function removeLinksAsync(terminal, targetRootFolder, extractorMetadataObject) {
9
+ await Async.forEachAsync(extractorMetadataObject.links, async ({ linkPath }) => {
10
+ const newLinkPath = path.join(targetRootFolder, linkPath);
11
+ terminal.writeVerboseLine(`Removing link at path "${newLinkPath}"`);
12
+ await FileSystem.deleteFileAsync(newLinkPath, { throwIfNotExists: false });
13
+ }, { concurrency: MAX_CONCURRENCY });
14
+ }
15
+ export class RemoveLinksAction extends CommandLineAction {
16
+ constructor(terminal) {
17
+ super({
18
+ actionName: 'remove',
19
+ summary: 'Remove symlinks created by the "create" action',
20
+ documentation: 'This action removes the symlinks created by the "create" action.'
21
+ });
22
+ this._terminal = terminal;
23
+ }
24
+ async onExecuteAsync() {
25
+ const extractorMetadataObject = await getExtractorMetadataAsync();
26
+ this._terminal.writeLine(`Removing links for extraction at path "${TARGET_ROOT_FOLDER}"`);
27
+ await removeLinksAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);
28
+ }
29
+ }
30
+ //# sourceMappingURL=RemoveLinksAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoveLinksAction.js","sourceRoot":"","sources":["../../../../../src/scripts/createLinks/cli/actions/RemoveLinksAction.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEhF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAmB,EACnB,gBAAwB,EACxB,uBAA+C;IAE/C,MAAM,KAAK,CAAC,YAAY,CACtB,uBAAuB,CAAC,KAAK,EAC7B,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrB,MAAM,WAAW,GAAW,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QAClE,QAAQ,CAAC,gBAAgB,CAAC,0BAA0B,WAAW,GAAG,CAAC,CAAC;QACpE,MAAM,UAAU,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC,EACD,EAAE,WAAW,EAAE,eAAe,EAAE,CACjC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,iBAAkB,SAAQ,iBAAiB;IAGtD,YAAmB,QAAmB;QACpC,KAAK,CAAC;YACJ,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,gDAAgD;YACzD,aAAa,EAAE,kEAAkE;SAClF,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAEkB,KAAK,CAAC,cAAc;QACrC,MAAM,uBAAuB,GAA2B,MAAM,yBAAyB,EAAE,CAAC;QAE1F,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,0CAA0C,kBAAkB,GAAG,CAAC,CAAC;QAC1F,MAAM,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;IACtF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport path from 'node:path';\n\nimport { Async, FileSystem } from '@rushstack/node-core-library';\nimport type { ITerminal } from '@rushstack/terminal';\nimport { CommandLineAction } from '@rushstack/ts-command-line';\n\nimport type { IExtractorMetadataJson } from '../../../../PackageExtractor';\nimport { getExtractorMetadataAsync } from '../../utilities/CreateLinksUtilities';\nimport { TARGET_ROOT_FOLDER, MAX_CONCURRENCY } from '../../utilities/constants';\n\nexport async function removeLinksAsync(\n terminal: ITerminal,\n targetRootFolder: string,\n extractorMetadataObject: IExtractorMetadataJson\n): Promise<void> {\n await Async.forEachAsync(\n extractorMetadataObject.links,\n async ({ linkPath }) => {\n const newLinkPath: string = path.join(targetRootFolder, linkPath);\n terminal.writeVerboseLine(`Removing link at path \"${newLinkPath}\"`);\n await FileSystem.deleteFileAsync(newLinkPath, { throwIfNotExists: false });\n },\n { concurrency: MAX_CONCURRENCY }\n );\n}\n\nexport class RemoveLinksAction extends CommandLineAction {\n private _terminal: ITerminal;\n\n public constructor(terminal: ITerminal) {\n super({\n actionName: 'remove',\n summary: 'Remove symlinks created by the \"create\" action',\n documentation: 'This action removes the symlinks created by the \"create\" action.'\n });\n\n this._terminal = terminal;\n }\n\n protected override async onExecuteAsync(): Promise<void> {\n const extractorMetadataObject: IExtractorMetadataJson = await getExtractorMetadataAsync();\n\n this._terminal.writeLine(`Removing links for extraction at path \"${TARGET_ROOT_FOLDER}\"`);\n await removeLinksAsync(this._terminal, TARGET_ROOT_FOLDER, extractorMetadataObject);\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ import { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';
4
+ import { CreateLinksCommandLineParser } from './cli/CreateLinksCommandLineParser';
5
+ const terminal = new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));
6
+ const parser = new CreateLinksCommandLineParser(terminal);
7
+ parser.executeAsync().catch(terminal.writeErrorLine);
8
+ //# sourceMappingURL=start.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../../src/scripts/createLinks/start.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAElF,MAAM,QAAQ,GAAa,IAAI,QAAQ,CAAC,IAAI,uBAAuB,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAE/F,MAAM,MAAM,GAAiC,IAAI,4BAA4B,CAAC,QAAQ,CAAC,CAAC;AACxF,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Terminal, ConsoleTerminalProvider } from '@rushstack/terminal';\n\nimport { CreateLinksCommandLineParser } from './cli/CreateLinksCommandLineParser';\n\nconst terminal: Terminal = new Terminal(new ConsoleTerminalProvider({ verboseEnabled: true }));\n\nconst parser: CreateLinksCommandLineParser = new CreateLinksCommandLineParser(terminal);\nparser.executeAsync().catch(terminal.writeErrorLine);\n"]}