@rushstack/package-extractor
Advanced tools
Comparing version 0.6.43 to 0.7.0
@@ -88,6 +88,11 @@ import { IPackageJson } from '@rushstack/node-core-library'; | ||
/** | ||
* The pnpmfile configuration if using PNPM, otherwise undefined. The configuration will be used to | ||
* The pnpmfile configuration if using PNPM, otherwise `undefined`. The configuration will be used to | ||
* transform the package.json prior to extraction. | ||
* | ||
* @remarks | ||
* When Rush subspaces are enabled, this setting applies to `default` subspace only. To configure | ||
* each subspace, use the {@link IExtractorOptions.subspaces} array instead. The two approaches | ||
* cannot be combined. | ||
*/ | ||
transformPackageJson?: (packageJson: IPackageJson) => IPackageJson | undefined; | ||
transformPackageJson?: (packageJson: IPackageJson) => IPackageJson; | ||
/** | ||
@@ -104,2 +109,7 @@ * If dependencies from the "devDependencies" package.json field should be included in the extraction. | ||
* to the PNPM virtual store. | ||
* | ||
* @remarks | ||
* When Rush subspaces are enabled, this setting applies to `default` subspace only. To configure | ||
* each subspace, use the {@link IExtractorOptions.subspaces} array instead. The two approaches | ||
* cannot be combined. | ||
*/ | ||
@@ -128,2 +138,11 @@ pnpmInstallFolder?: string; | ||
dependencyConfigurations?: IExtractorDependencyConfiguration[]; | ||
/** | ||
* When using Rush subspaces, this setting can be used to provide configuration information for each | ||
* individual subspace. | ||
* | ||
* @remarks | ||
* To avoid confusion, if this setting is used, then the {@link IExtractorOptions.transformPackageJson} and | ||
* {@link IExtractorOptions.pnpmInstallFolder} settings must not be used. | ||
*/ | ||
subspaces?: IExtractorSubspace[]; | ||
} | ||
@@ -172,2 +191,24 @@ | ||
/** | ||
* The extractor subspace configurations | ||
* | ||
* @public | ||
*/ | ||
export declare interface IExtractorSubspace { | ||
/** | ||
* The subspace name | ||
*/ | ||
subspaceName: string; | ||
/** | ||
* The folder where the PNPM "node_modules" folder is located. This is used to resolve packages linked | ||
* to the PNPM virtual store. | ||
*/ | ||
pnpmInstallFolder?: string; | ||
/** | ||
* The pnpmfile configuration if using PNPM, otherwise undefined. The configuration will be used to | ||
* transform the package.json prior to extraction. | ||
*/ | ||
transformPackageJson?: (packageJson: IPackageJson) => IPackageJson; | ||
} | ||
/** | ||
* Represents a symbolic link. | ||
@@ -224,2 +265,3 @@ * | ||
extractAsync(options: IExtractorOptions): Promise<void>; | ||
private static _normalizeOptions; | ||
private _performExtractionAsync; | ||
@@ -226,0 +268,0 @@ /** |
@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard. | ||
"packageName": "@microsoft/api-extractor", | ||
"packageVersion": "7.43.0" | ||
"packageVersion": "7.43.1" | ||
} | ||
] | ||
} |
@@ -1,3 +0,3 @@ | ||
export { PackageExtractor, type IExtractorOptions, type IExtractorProjectConfiguration, type IExtractorDependencyConfiguration, type IExtractorMetadataJson, type IProjectInfoJson } from './PackageExtractor'; | ||
export { PackageExtractor, type IExtractorOptions, type IExtractorProjectConfiguration, type IExtractorDependencyConfiguration, type IExtractorMetadataJson, type IProjectInfoJson, type IExtractorSubspace } from './PackageExtractor'; | ||
export type { ILinkInfo } from './SymlinkAnalyzer'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -50,2 +50,23 @@ import { type IPackageJson } from '@rushstack/node-core-library'; | ||
/** | ||
* The extractor subspace configurations | ||
* | ||
* @public | ||
*/ | ||
export interface IExtractorSubspace { | ||
/** | ||
* The subspace name | ||
*/ | ||
subspaceName: string; | ||
/** | ||
* The folder where the PNPM "node_modules" folder is located. This is used to resolve packages linked | ||
* to the PNPM virtual store. | ||
*/ | ||
pnpmInstallFolder?: string; | ||
/** | ||
* The pnpmfile configuration if using PNPM, otherwise undefined. The configuration will be used to | ||
* transform the package.json prior to extraction. | ||
*/ | ||
transformPackageJson?: (packageJson: IPackageJson) => IPackageJson; | ||
} | ||
/** | ||
* The extractor configuration for individual projects. | ||
@@ -152,6 +173,11 @@ * | ||
/** | ||
* The pnpmfile configuration if using PNPM, otherwise undefined. The configuration will be used to | ||
* The pnpmfile configuration if using PNPM, otherwise `undefined`. The configuration will be used to | ||
* transform the package.json prior to extraction. | ||
* | ||
* @remarks | ||
* When Rush subspaces are enabled, this setting applies to `default` subspace only. To configure | ||
* each subspace, use the {@link IExtractorOptions.subspaces} array instead. The two approaches | ||
* cannot be combined. | ||
*/ | ||
transformPackageJson?: (packageJson: IPackageJson) => IPackageJson | undefined; | ||
transformPackageJson?: (packageJson: IPackageJson) => IPackageJson; | ||
/** | ||
@@ -168,2 +194,7 @@ * If dependencies from the "devDependencies" package.json field should be included in the extraction. | ||
* to the PNPM virtual store. | ||
* | ||
* @remarks | ||
* When Rush subspaces are enabled, this setting applies to `default` subspace only. To configure | ||
* each subspace, use the {@link IExtractorOptions.subspaces} array instead. The two approaches | ||
* cannot be combined. | ||
*/ | ||
@@ -192,2 +223,11 @@ pnpmInstallFolder?: string; | ||
dependencyConfigurations?: IExtractorDependencyConfiguration[]; | ||
/** | ||
* When using Rush subspaces, this setting can be used to provide configuration information for each | ||
* individual subspace. | ||
* | ||
* @remarks | ||
* To avoid confusion, if this setting is used, then the {@link IExtractorOptions.transformPackageJson} and | ||
* {@link IExtractorOptions.pnpmInstallFolder} settings must not be used. | ||
*/ | ||
subspaces?: IExtractorSubspace[]; | ||
} | ||
@@ -210,2 +250,3 @@ /** | ||
extractAsync(options: IExtractorOptions): Promise<void>; | ||
private static _normalizeOptions; | ||
private _performExtractionAsync; | ||
@@ -212,0 +253,0 @@ /** |
@@ -72,2 +72,3 @@ "use strict"; | ||
async extractAsync(options) { | ||
options = PackageExtractor._normalizeOptions(options); | ||
const { terminal, projectConfigurations, sourceRootFolder, targetRootFolder, mainProjectName, overwriteExisting, createArchiveFilePath, createArchiveOnly, dependencyConfigurations } = options; | ||
@@ -138,2 +139,24 @@ if (createArchiveOnly) { | ||
} | ||
static _normalizeOptions(options) { | ||
if (options.subspaces) { | ||
if (options.pnpmInstallFolder !== undefined) { | ||
throw new Error('IExtractorOptions.pnpmInstallFolder cannot be combined with IExtractorOptions.subspaces'); | ||
} | ||
if (options.transformPackageJson !== undefined) { | ||
throw new Error('IExtractorOptions.transformPackageJson cannot be combined with IExtractorOptions.subspaces'); | ||
} | ||
return options; | ||
} | ||
const normalizedOptions = Object.assign({}, options); | ||
delete normalizedOptions.pnpmInstallFolder; | ||
delete normalizedOptions.transformPackageJson; | ||
normalizedOptions.subspaces = [ | ||
{ | ||
subspaceName: 'default', | ||
pnpmInstallFolder: options.pnpmInstallFolder, | ||
transformPackageJson: options.transformPackageJson | ||
} | ||
]; | ||
return normalizedOptions; | ||
} | ||
async _performExtractionAsync(options, state) { | ||
@@ -216,7 +239,7 @@ var _a; | ||
async _collectFoldersAsync(packageJsonFolder, options, state) { | ||
const { terminal, pnpmInstallFolder, transformPackageJson } = options; | ||
const { terminal, subspaces } = options; | ||
const { projectConfigurationsByPath } = state; | ||
const packageJsonFolderPathQueue = new node_core_library_1.AsyncQueue([packageJsonFolder]); | ||
await node_core_library_1.Async.forEachAsync(packageJsonFolderPathQueue, async ([packageJsonFolderPath, callback]) => { | ||
var _a; | ||
var _a, _b; | ||
const packageJsonRealFolderPath = await node_core_library_1.FileSystem.getRealPathAsync(packageJsonFolderPath); | ||
@@ -230,4 +253,5 @@ if (state.foldersToCopy.has(packageJsonRealFolderPath)) { | ||
const originalPackageJson = await node_core_library_1.JsonFile.loadAsync(path.join(packageJsonRealFolderPath, 'package.json')); | ||
const targetSubspace = subspaces === null || subspaces === void 0 ? void 0 : subspaces.find((subspace) => subspace.pnpmInstallFolder && node_core_library_1.Path.isUnder(packageJsonFolderPath, subspace.pnpmInstallFolder)); | ||
// Transform packageJson using the provided transformer, if requested | ||
const packageJson = (_a = transformPackageJson === null || transformPackageJson === void 0 ? void 0 : transformPackageJson(originalPackageJson)) !== null && _a !== void 0 ? _a : originalPackageJson; | ||
const packageJson = (_b = (_a = targetSubspace === null || targetSubspace === void 0 ? void 0 : targetSubspace.transformPackageJson) === null || _a === void 0 ? void 0 : _a.call(targetSubspace, originalPackageJson)) !== null && _b !== void 0 ? _b : originalPackageJson; | ||
state.packageJsonByPath.set(packageJsonRealFolderPath, packageJson); | ||
@@ -290,3 +314,4 @@ // Union of keys from regular dependencies, peerDependencies, optionalDependencies | ||
// Only apply this logic for packages that were actually installed under the common/temp folder. | ||
if (pnpmInstallFolder && node_core_library_1.Path.isUnder(packageJsonFolderPath, pnpmInstallFolder)) { | ||
const realPnpmInstallFolder = targetSubspace === null || targetSubspace === void 0 ? void 0 : targetSubspace.pnpmInstallFolder; | ||
if (realPnpmInstallFolder && node_core_library_1.Path.isUnder(packageJsonFolderPath, realPnpmInstallFolder)) { | ||
try { | ||
@@ -296,3 +321,3 @@ // The PNPM virtual store links are created in this folder. We will resolve the current package | ||
// TODO: This can be configured via NPMRC. We should support that. | ||
const pnpmDotFolderPath = path.join(pnpmInstallFolder, 'node_modules', '.pnpm'); | ||
const pnpmDotFolderPath = path.join(realPnpmInstallFolder, 'node_modules', '.pnpm'); | ||
// TODO: Investigate how package aliases are handled by PNPM in this case. For example: | ||
@@ -299,0 +324,0 @@ // |
{ | ||
"name": "@rushstack/package-extractor", | ||
"version": "0.6.43", | ||
"version": "0.7.0", | ||
"description": "A library for bundling selected files and dependencies into a deployable package.", | ||
@@ -27,9 +27,9 @@ "main": "lib/index.js", | ||
"@types/npm-packlist": "~1.1.1", | ||
"eslint": "~8.7.0", | ||
"eslint": "~8.57.0", | ||
"webpack": "~5.82.1", | ||
"@types/semver": "7.5.0", | ||
"local-node-rig": "1.0.0", | ||
"@rushstack/heft-webpack5-plugin": "0.9.40", | ||
"@rushstack/webpack-preserve-dynamic-require-plugin": "0.11.40", | ||
"@rushstack/heft": "0.66.3", | ||
"@rushstack/webpack-preserve-dynamic-require-plugin": "0.11.40" | ||
"local-node-rig": "1.0.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199161
1969