@rushstack/rush-resolver-cache-plugin 5.158.1 → 5.159.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afterInstallAsync.d.ts","sourceRoot":"","sources":["../src/afterInstallAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAEjB,OAAO,EAEP,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAmD7B;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"afterInstallAsync.d.ts","sourceRoot":"","sources":["../src/afterInstallAsync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAEjB,OAAO,EAEP,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAmD7B;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,WAAW,EACxB,iBAAiB,EAAE,iBAAiB,EACpC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAgNf"}
|
package/lib/afterInstallAsync.js
CHANGED
|
@@ -24,7 +24,7 @@ function getPlatformInfo() {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
const END_TOKEN = '/package.json":';
|
|
27
|
-
const RESOLVER_CACHE_FILE_VERSION =
|
|
27
|
+
const RESOLVER_CACHE_FILE_VERSION = 2;
|
|
28
28
|
/**
|
|
29
29
|
* Plugin entry point for after install.
|
|
30
30
|
* @param rushSession - The Rush Session
|
|
@@ -48,6 +48,9 @@ async function afterInstallAsync(rushSession, rushConfiguration, subspace, varia
|
|
|
48
48
|
if (!lockFile) {
|
|
49
49
|
throw new Error(`Failed to load shrinkwrap file: ${lockFilePath}`);
|
|
50
50
|
}
|
|
51
|
+
if (!lockFile.hash) {
|
|
52
|
+
throw new Error(`Shrinkwrap file does not have a hash. This indicates linking to an old version of Rush.`);
|
|
53
|
+
}
|
|
51
54
|
try {
|
|
52
55
|
const oldCacheFileContent = await externals_1.FileSystem.readFileAsync(cacheFilePath);
|
|
53
56
|
const oldCache = JSON.parse(oldCacheFileContent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afterInstallAsync.js","sourceRoot":"","sources":["../src/afterInstallAsync.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAoE3D,8CAgNC;AAxQD,2CAAoE;AACpE,mGAGiD;AAGjD;;;GAGG;AACH,SAAS,eAAe;;IACtB,6EAA6E;IAC7E,qDAAqD;IACrD,MAAM,EACJ,QAAQ,EAAE,EAAE,EACZ,IAAI,EAAE,GAAG,EACT,mBAAmB;IACnB,8DAA8D;MAC/D,GAAG,MAAA,MAAC,MAAA,OAAO,CAAC,MAAM,0CAAE,SAAS,EAAU,0CAAE,MAAM,mCAAI,OAAO,CAAC;IAC5D,MAAM,IAAI,GAAqB,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAEtE,OAAO;QACL,EAAE;QACF,GAAG;QACH,IAAI;KACL,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAW,iBAAiB,CAAC;AAC5C,MAAM,2BAA2B,GAAM,CAAC,CAAC;AAkBzC;;;;;;;GAOG;AACI,KAAK,UAAU,iBAAiB,CACrC,WAAwB,EACxB,iBAAoC,EACpC,QAAkB,EAClB,OAA2B,EAC3B,MAAe;IAEf,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,C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AC,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,qCAAqC,EAAE;YACjF,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,YAAY,GAAuB,MAAM,IAAA,6EAAqC,EAAC;QACnF,aAAa;QACb,kBAAkB,EAAE,QAAQ;QAC5B,YAAY,EAAE,eAAe,EAAE;QAC/B,qBAAqB;QACrB,QAAQ,EAAE,QAAQ;QAClB,0BAA0B;KAC3B,CAAC,CAAC;IAEH,MAAM,iBAAiB,GAA+B;QACpD,OAAO,EAAE,2BAA2B;QACpC,cAAc,EAAE,QAAQ,CAAC,IAAI;QAC7B,GAAG,YAAY;KAChB,CAAC;IAEF,MAAM,kBAAkB,GAA4B;QAClD,OAAO,EAAE,2BAA2B;QACpC,sBAAsB,EAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;KAC3D,CAAC;IACF,MAAM,yBAAyB,GAAW,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAE7E,MAAM,UAAU,GAAW,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAE7D,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,sBAAU,CAAC,cAAc,CAAC,aAAa,EAAE,UAAU,EAAE;YACnD,kBAAkB,EAAE,IAAI;SACzB,CAAC;QACF,sBAAU,CAAC,cAAc,CAAC,uBAAuB,EAAE,yBAAyB,EAAE;YAC5E,kBAAkB,EAAE,IAAI;SACzB,CAAC;KACH,CAAC,CAAC;IAEH,oGAAoG;IACpG,8BAAkB,CAAC,UAAU,EAAE,CAAC;IAEhC,QAAQ,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;AAChD,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 type {\n RushSession,\n RushConfiguration,\n RushConfigurationProject,\n ILogger,\n LookupByPath,\n Subspace\n} from '@rushstack/rush-sdk';\nimport type { IResolverCacheFile } from '@rushstack/webpack-workspace-resolve-plugin';\n\nimport { Async, FileSystem, PnpmShrinkwrapFile } from './externals';\nimport {\n computeResolverCacheFromLockfileAsync,\n type IPlatformInfo\n} from './computeResolverCacheFromLockfileAsync';\nimport type { IResolverContext } from './types';\n\n/**\n * Gets information used to determine compatibility of optional dependencies.\n * @returns Information about the platform Rush is running on\n */\nfunction getPlatformInfo(): IPlatformInfo {\n // Acquiring the libc version is a bit more obnoxious than platform and arch,\n // but all of them are ultimately on the same object.\n const {\n platform: os,\n arch: cpu,\n glibcVersionRuntime\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } = (process.report?.getReport() as any)?.header ?? process;\n const libc: 'glibc' | 'musl' = glibcVersionRuntime ? 'glibc' : 'musl';\n\n return {\n os,\n cpu,\n libc\n };\n}\n\nconst END_TOKEN: string = '/package.json\":';\nconst RESOLVER_CACHE_FILE_VERSION: 1 = 1;\n\ninterface IExtendedResolverCacheFile extends IResolverCacheFile {\n /**\n * The hash of the shrinkwrap file this cache file was generated from.\n */\n shrinkwrapHash: string;\n /**\n * The version of the resolver cache file.\n */\n version: number;\n}\n\ninterface INestedPackageJsonCache {\n subPackagesByIntegrity: [string, string[] | boolean][];\n version: number;\n}\n\n/**\n * Plugin entry point for after install.\n * @param rushSession - The Rush Session\n * @param rushConfiguration - The Rush Configuration\n * @param subspace - The subspace that was just installed\n * @param variant - The variant that was just installed\n * @param logger - The initialized logger\n */\nexport async function afterInstallAsync(\n rushSession: RushSession,\n rushConfiguration: RushConfiguration,\n subspace: Subspace,\n variant: string | undefined,\n logger: ILogger\n): Promise<void> {\n const { terminal } = logger;\n const rushRoot: string = `${rushConfiguration.rushJsonFolder}/`;\n\n const lockFilePath: string = subspace.getCommittedShrinkwrapFilePath(variant);\n\n const pnpmStoreDir: string = `${rushConfiguration.pnpmOptions.pnpmStorePath}/v3/files/`;\n\n terminal.writeLine(`Using pnpm-lock from: ${lockFilePath}`);\n terminal.writeLine(`Using pnpm store folder: ${pnpmStoreDir}`);\n\n const workspaceRoot: string = subspace.getSubspaceTempFolderPath();\n const cacheFilePath: string = `${workspaceRoot}/resolver-cache.json`;\n\n const lockFile: PnpmShrinkwrapFile | undefined = PnpmShrinkwrapFile.loadFromFile(lockFilePath, {\n withCaching: true\n });\n if (!lockFile) {\n throw new Error(`Failed to load shrinkwrap file: ${lockFilePath}`);\n }\n\n try {\n const oldCacheFileContent: string = await FileSystem.readFileAsync(cacheFilePath);\n const oldCache: IExtendedResolverCacheFile = JSON.parse(oldCacheFileContent);\n if (oldCache.version === RESOLVER_CACHE_FILE_VERSION && oldCache.shrinkwrapHash === lockFile.hash) {\n // Cache is valid, use it\n return;\n }\n } catch (err) {\n // Ignore\n }\n\n const projectByImporterPath: LookupByPath<RushConfigurationProject> =\n rushConfiguration.getProjectLookupForRoot(workspaceRoot);\n\n const subPackageCacheFilePath: string = `${workspaceRoot}/subpackage-entry-cache.json`;\n\n terminal.writeLine(`Resolver cache will be written at ${cacheFilePath}`);\n\n let oldSubPackagesByIntegrity: Map<string, string[] | boolean> | undefined;\n const subPackagesByIntegrity: Map<string, string[] | boolean> = new Map();\n try {\n const cacheContent: string = await FileSystem.readFileAsync(subPackageCacheFilePath);\n const cacheJson: INestedPackageJsonCache = JSON.parse(cacheContent);\n if (cacheJson.version !== RESOLVER_CACHE_FILE_VERSION) {\n terminal.writeLine(\n `Expected subpackage cache version ${RESOLVER_CACHE_FILE_VERSION}, got ${cacheJson.version}`\n );\n } else {\n oldSubPackagesByIntegrity = new Map(cacheJson.subPackagesByIntegrity);\n terminal.writeLine(`Loaded subpackage cache from ${subPackageCacheFilePath}`);\n }\n } catch (err) {\n // Ignore\n }\n\n async function afterExternalPackagesAsync(\n contexts: Map<string, IResolverContext>,\n missingOptionalDependencies: Set<string>\n ): Promise<void> {\n /**\n * Loads the index file from the pnpm store to discover nested package.json files in an external package\n * For internal packages, assumes there are no nested package.json files.\n * @param context - The context to find nested package.json files for\n * @returns A promise that resolves to the nested package.json paths, false if the package fails to load, or true if the package has no nested package.json files.\n */\n async function tryFindNestedPackageJsonsForContextAsync(\n context: IResolverContext\n ): Promise<string[] | boolean> {\n const { descriptionFileRoot, descriptionFileHash } = context;\n\n if (descriptionFileHash === undefined) {\n // Assume this package has no nested package json files for now.\n terminal.writeDebugLine(\n `Package at ${descriptionFileRoot} does not have a file list. Assuming no nested \"package.json\" files.`\n );\n return true;\n }\n\n // Convert an integrity hash like\n // sha512-C6uiGQJ+Gt4RyHXXYt+v9f+SN1v83x68URwgxNQ98cvH8kxiuywWGP4XeNZ1paOzZ63aY3cTciCEQJNFUljlLw==\n // To its hex representation, e.g.\n // 0baba219027e1ade11c875d762dfaff5ff92375bfcdf1ebc511c20c4d43df1cbc7f24c62bb2c1618fe1778d675a5a3b367adda6377137220844093455258e52f\n const prefixIndex: number = descriptionFileHash.indexOf('-');\n const hash: string = Buffer.from(descriptionFileHash.slice(prefixIndex + 1), 'base64').toString('hex');\n\n // The pnpm store directory has index files of package contents at paths:\n // <store>/v3/files/<hash (0-2)>/<hash (2-)>-index.json\n // See https://github.com/pnpm/pnpm/blob/f394cfccda7bc519ceee8c33fc9b68a0f4235532/store/cafs/src/getFilePathInCafs.ts#L33\n const indexPath: string = `${pnpmStoreDir}${hash.slice(0, 2)}/${hash.slice(2)}-index.json`;\n\n try {\n const indexContent: string = await FileSystem.readFileAsync(indexPath);\n let endIndex: number = indexContent.lastIndexOf(END_TOKEN);\n if (endIndex > 0) {\n const nestedPackageDirs: string[] = [];\n do {\n const startIndex: number = indexContent.lastIndexOf('\"', endIndex);\n if (startIndex < 0) {\n throw new Error(\n `Malformed index file at ${indexPath}: missing starting quote for nested package.json path`\n );\n }\n const nestedPath: string = indexContent.slice(startIndex + 1, endIndex);\n nestedPackageDirs.push(nestedPath);\n endIndex = indexContent.lastIndexOf(END_TOKEN, startIndex - 1);\n } while (endIndex > 0);\n return nestedPackageDirs;\n }\n return true;\n } catch (error) {\n if (!context.optional) {\n throw new Error(\n `Error reading index file for: \"${context.descriptionFileRoot}\" (${descriptionFileHash}): ${error.toString()}`\n );\n }\n return false;\n }\n }\n /**\n * Loads the index file from the pnpm store to discover nested package.json files in an external package\n * For internal packages, assumes there are no nested package.json files.\n * @param context - The context to find nested package.json files for\n * @returns A promise that resolves when the nested package.json files are found, if applicable\n */\n async function findNestedPackageJsonsForContextAsync(context: IResolverContext): Promise<void> {\n const { descriptionFileRoot, descriptionFileHash } = context;\n\n if (descriptionFileHash === undefined) {\n // Assume this package has no nested package json files for now.\n terminal.writeDebugLine(\n `Package at ${descriptionFileRoot} does not have a file list. Assuming no nested \"package.json\" files.`\n );\n return;\n }\n\n let result: string[] | boolean | undefined =\n oldSubPackagesByIntegrity?.get(descriptionFileHash) ??\n subPackagesByIntegrity.get(descriptionFileHash);\n if (result === undefined) {\n result = await tryFindNestedPackageJsonsForContextAsync(context);\n }\n subPackagesByIntegrity.set(descriptionFileHash, result);\n if (result === true) {\n // Default case. Do nothing.\n } else if (result === false) {\n terminal.writeLine(`Trimming missing optional dependency at: ${descriptionFileRoot}`);\n contexts.delete(descriptionFileRoot);\n missingOptionalDependencies.add(descriptionFileRoot);\n } else {\n terminal.writeDebugLine(\n `Nested \"package.json\" files found for package at ${descriptionFileRoot}: ${result.join(', ')}`\n );\n // eslint-disable-next-line require-atomic-updates\n context.nestedPackageDirs = result;\n }\n }\n\n // For external packages, update the contexts with data from the pnpm store\n // This gives us the list of nested package.json files, as well as the actual package name\n // We could also cache package.json contents, but that proves to be inefficient.\n await Async.forEachAsync(contexts.values(), findNestedPackageJsonsForContextAsync, {\n concurrency: 20\n });\n }\n\n const rawCacheFile: IResolverCacheFile = await computeResolverCacheFromLockfileAsync({\n workspaceRoot,\n commonPrefixToTrim: rushRoot,\n platformInfo: getPlatformInfo(),\n projectByImporterPath,\n lockfile: lockFile,\n afterExternalPackagesAsync\n });\n\n const extendedCacheFile: IExtendedResolverCacheFile = {\n version: RESOLVER_CACHE_FILE_VERSION,\n shrinkwrapHash: lockFile.hash,\n ...rawCacheFile\n };\n\n const newSubPackageCache: INestedPackageJsonCache = {\n version: RESOLVER_CACHE_FILE_VERSION,\n subPackagesByIntegrity: Array.from(subPackagesByIntegrity)\n };\n const serializedSubpackageCache: string = JSON.stringify(newSubPackageCache);\n\n const serialized: string = JSON.stringify(extendedCacheFile);\n\n await Promise.all([\n FileSystem.writeFileAsync(cacheFilePath, serialized, {\n ensureFolderExists: true\n }),\n FileSystem.writeFileAsync(subPackageCacheFilePath, serializedSubpackageCache, {\n ensureFolderExists: true\n })\n ]);\n\n // Free the memory used by the lockfiles, since nothing should read the lockfile from this point on.\n PnpmShrinkwrapFile.clearCache();\n\n terminal.writeLine(`Resolver cache written.`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"afterInstallAsync.js","sourceRoot":"","sources":["../src/afterInstallAsync.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAoE3D,8CAsNC;AA9QD,2CAAoE;AACpE,mGAGiD;AAGjD;;;GAGG;AACH,SAAS,eAAe;;IACtB,6EAA6E;IAC7E,qDAAqD;IACrD,MAAM,EACJ,QAAQ,EAAE,EAAE,EACZ,IAAI,EAAE,GAAG,EACT,mBAAmB;IACnB,8DAA8D;MAC/D,GAAG,MAAA,MAAC,MAAA,OAAO,CAAC,MAAM,0CAAE,SAAS,EAAU,0CAAE,MAAM,mCAAI,OAAO,CAAC;IAC5D,MAAM,IAAI,GAAqB,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAEtE,OAAO;QACL,EAAE;QACF,GAAG;QACH,IAAI;KACL,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAW,iBAAiB,CAAC;AAC5C,MAAM,2BAA2B,GAAM,CAAC,CAAC;AAkBzC;;;;;;;GAOG;AACI,KAAK,UAAU,iBAAiB,CACrC,WAAwB,EACxB,iBAAoC,EACpC,QAAkB,EAClB,OAA2B,EAC3B,MAAe;IAEf,MAAM,E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corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type {\n RushSession,\n RushConfiguration,\n RushConfigurationProject,\n ILogger,\n LookupByPath,\n Subspace\n} from '@rushstack/rush-sdk';\nimport type { IResolverCacheFile } from '@rushstack/webpack-workspace-resolve-plugin';\n\nimport { Async, FileSystem, PnpmShrinkwrapFile } from './externals';\nimport {\n computeResolverCacheFromLockfileAsync,\n type IPlatformInfo\n} from './computeResolverCacheFromLockfileAsync';\nimport type { IResolverContext } from './types';\n\n/**\n * Gets information used to determine compatibility of optional dependencies.\n * @returns Information about the platform Rush is running on\n */\nfunction getPlatformInfo(): IPlatformInfo {\n // Acquiring the libc version is a bit more obnoxious than platform and arch,\n // but all of them are ultimately on the same object.\n const {\n platform: os,\n arch: cpu,\n glibcVersionRuntime\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } = (process.report?.getReport() as any)?.header ?? process;\n const libc: 'glibc' | 'musl' = glibcVersionRuntime ? 'glibc' : 'musl';\n\n return {\n os,\n cpu,\n libc\n };\n}\n\nconst END_TOKEN: string = '/package.json\":';\nconst RESOLVER_CACHE_FILE_VERSION: 2 = 2;\n\ninterface IExtendedResolverCacheFile extends IResolverCacheFile {\n /**\n * The hash of the shrinkwrap file this cache file was generated from.\n */\n shrinkwrapHash: string;\n /**\n * The version of the resolver cache file.\n */\n version: number;\n}\n\ninterface INestedPackageJsonCache {\n subPackagesByIntegrity: [string, string[] | boolean][];\n version: number;\n}\n\n/**\n * Plugin entry point for after install.\n * @param rushSession - The Rush Session\n * @param rushConfiguration - The Rush Configuration\n * @param subspace - The subspace that was just installed\n * @param variant - The variant that was just installed\n * @param logger - The initialized logger\n */\nexport async function afterInstallAsync(\n rushSession: RushSession,\n rushConfiguration: RushConfiguration,\n subspace: Subspace,\n variant: string | undefined,\n logger: ILogger\n): Promise<void> {\n const { terminal } = logger;\n const rushRoot: string = `${rushConfiguration.rushJsonFolder}/`;\n\n const lockFilePath: string = subspace.getCommittedShrinkwrapFilePath(variant);\n\n const pnpmStoreDir: string = `${rushConfiguration.pnpmOptions.pnpmStorePath}/v3/files/`;\n\n terminal.writeLine(`Using pnpm-lock from: ${lockFilePath}`);\n terminal.writeLine(`Using pnpm store folder: ${pnpmStoreDir}`);\n\n const workspaceRoot: string = subspace.getSubspaceTempFolderPath();\n const cacheFilePath: string = `${workspaceRoot}/resolver-cache.json`;\n\n const lockFile: PnpmShrinkwrapFile | undefined = PnpmShrinkwrapFile.loadFromFile(lockFilePath, {\n withCaching: true\n });\n if (!lockFile) {\n throw new Error(`Failed to load shrinkwrap file: ${lockFilePath}`);\n }\n\n if (!lockFile.hash) {\n throw new Error(\n `Shrinkwrap file does not have a hash. This indicates linking to an old version of Rush.`\n );\n }\n\n try {\n const oldCacheFileContent: string = await FileSystem.readFileAsync(cacheFilePath);\n const oldCache: IExtendedResolverCacheFile = JSON.parse(oldCacheFileContent);\n if (oldCache.version === RESOLVER_CACHE_FILE_VERSION && oldCache.shrinkwrapHash === lockFile.hash) {\n // Cache is valid, use it\n return;\n }\n } catch (err) {\n // Ignore\n }\n\n const projectByImporterPath: LookupByPath<RushConfigurationProject> =\n rushConfiguration.getProjectLookupForRoot(workspaceRoot);\n\n const subPackageCacheFilePath: string = `${workspaceRoot}/subpackage-entry-cache.json`;\n\n terminal.writeLine(`Resolver cache will be written at ${cacheFilePath}`);\n\n let oldSubPackagesByIntegrity: Map<string, string[] | boolean> | undefined;\n const subPackagesByIntegrity: Map<string, string[] | boolean> = new Map();\n try {\n const cacheContent: string = await FileSystem.readFileAsync(subPackageCacheFilePath);\n const cacheJson: INestedPackageJsonCache = JSON.parse(cacheContent);\n if (cacheJson.version !== RESOLVER_CACHE_FILE_VERSION) {\n terminal.writeLine(\n `Expected subpackage cache version ${RESOLVER_CACHE_FILE_VERSION}, got ${cacheJson.version}`\n );\n } else {\n oldSubPackagesByIntegrity = new Map(cacheJson.subPackagesByIntegrity);\n terminal.writeLine(`Loaded subpackage cache from ${subPackageCacheFilePath}`);\n }\n } catch (err) {\n // Ignore\n }\n\n async function afterExternalPackagesAsync(\n contexts: Map<string, IResolverContext>,\n missingOptionalDependencies: Set<string>\n ): Promise<void> {\n /**\n * Loads the index file from the pnpm store to discover nested package.json files in an external package\n * For internal packages, assumes there are no nested package.json files.\n * @param context - The context to find nested package.json files for\n * @returns A promise that resolves to the nested package.json paths, false if the package fails to load, or true if the package has no nested package.json files.\n */\n async function tryFindNestedPackageJsonsForContextAsync(\n context: IResolverContext\n ): Promise<string[] | boolean> {\n const { descriptionFileRoot, descriptionFileHash } = context;\n\n if (descriptionFileHash === undefined) {\n // Assume this package has no nested package json files for now.\n terminal.writeDebugLine(\n `Package at ${descriptionFileRoot} does not have a file list. Assuming no nested \"package.json\" files.`\n );\n return true;\n }\n\n // Convert an integrity hash like\n // sha512-C6uiGQJ+Gt4RyHXXYt+v9f+SN1v83x68URwgxNQ98cvH8kxiuywWGP4XeNZ1paOzZ63aY3cTciCEQJNFUljlLw==\n // To its hex representation, e.g.\n // 0baba219027e1ade11c875d762dfaff5ff92375bfcdf1ebc511c20c4d43df1cbc7f24c62bb2c1618fe1778d675a5a3b367adda6377137220844093455258e52f\n const prefixIndex: number = descriptionFileHash.indexOf('-');\n const hash: string = Buffer.from(descriptionFileHash.slice(prefixIndex + 1), 'base64').toString('hex');\n\n // The pnpm store directory has index files of package contents at paths:\n // <store>/v3/files/<hash (0-2)>/<hash (2-)>-index.json\n // See https://github.com/pnpm/pnpm/blob/f394cfccda7bc519ceee8c33fc9b68a0f4235532/store/cafs/src/getFilePathInCafs.ts#L33\n const indexPath: string = `${pnpmStoreDir}${hash.slice(0, 2)}/${hash.slice(2)}-index.json`;\n\n try {\n const indexContent: string = await FileSystem.readFileAsync(indexPath);\n let endIndex: number = indexContent.lastIndexOf(END_TOKEN);\n if (endIndex > 0) {\n const nestedPackageDirs: string[] = [];\n do {\n const startIndex: number = indexContent.lastIndexOf('\"', endIndex);\n if (startIndex < 0) {\n throw new Error(\n `Malformed index file at ${indexPath}: missing starting quote for nested package.json path`\n );\n }\n const nestedPath: string = indexContent.slice(startIndex + 1, endIndex);\n nestedPackageDirs.push(nestedPath);\n endIndex = indexContent.lastIndexOf(END_TOKEN, startIndex - 1);\n } while (endIndex > 0);\n return nestedPackageDirs;\n }\n return true;\n } catch (error) {\n if (!context.optional) {\n throw new Error(\n `Error reading index file for: \"${context.descriptionFileRoot}\" (${descriptionFileHash}): ${error.toString()}`\n );\n }\n return false;\n }\n }\n /**\n * Loads the index file from the pnpm store to discover nested package.json files in an external package\n * For internal packages, assumes there are no nested package.json files.\n * @param context - The context to find nested package.json files for\n * @returns A promise that resolves when the nested package.json files are found, if applicable\n */\n async function findNestedPackageJsonsForContextAsync(context: IResolverContext): Promise<void> {\n const { descriptionFileRoot, descriptionFileHash } = context;\n\n if (descriptionFileHash === undefined) {\n // Assume this package has no nested package json files for now.\n terminal.writeDebugLine(\n `Package at ${descriptionFileRoot} does not have a file list. Assuming no nested \"package.json\" files.`\n );\n return;\n }\n\n let result: string[] | boolean | undefined =\n oldSubPackagesByIntegrity?.get(descriptionFileHash) ??\n subPackagesByIntegrity.get(descriptionFileHash);\n if (result === undefined) {\n result = await tryFindNestedPackageJsonsForContextAsync(context);\n }\n subPackagesByIntegrity.set(descriptionFileHash, result);\n if (result === true) {\n // Default case. Do nothing.\n } else if (result === false) {\n terminal.writeLine(`Trimming missing optional dependency at: ${descriptionFileRoot}`);\n contexts.delete(descriptionFileRoot);\n missingOptionalDependencies.add(descriptionFileRoot);\n } else {\n terminal.writeDebugLine(\n `Nested \"package.json\" files found for package at ${descriptionFileRoot}: ${result.join(', ')}`\n );\n // eslint-disable-next-line require-atomic-updates\n context.nestedPackageDirs = result;\n }\n }\n\n // For external packages, update the contexts with data from the pnpm store\n // This gives us the list of nested package.json files, as well as the actual package name\n // We could also cache package.json contents, but that proves to be inefficient.\n await Async.forEachAsync(contexts.values(), findNestedPackageJsonsForContextAsync, {\n concurrency: 20\n });\n }\n\n const rawCacheFile: IResolverCacheFile = await computeResolverCacheFromLockfileAsync({\n workspaceRoot,\n commonPrefixToTrim: rushRoot,\n platformInfo: getPlatformInfo(),\n projectByImporterPath,\n lockfile: lockFile,\n afterExternalPackagesAsync\n });\n\n const extendedCacheFile: IExtendedResolverCacheFile = {\n version: RESOLVER_CACHE_FILE_VERSION,\n shrinkwrapHash: lockFile.hash,\n ...rawCacheFile\n };\n\n const newSubPackageCache: INestedPackageJsonCache = {\n version: RESOLVER_CACHE_FILE_VERSION,\n subPackagesByIntegrity: Array.from(subPackagesByIntegrity)\n };\n const serializedSubpackageCache: string = JSON.stringify(newSubPackageCache);\n\n const serialized: string = JSON.stringify(extendedCacheFile);\n\n await Promise.all([\n FileSystem.writeFileAsync(cacheFilePath, serialized, {\n ensureFolderExists: true\n }),\n FileSystem.writeFileAsync(subPackageCacheFilePath, serializedSubpackageCache, {\n ensureFolderExists: true\n })\n ]);\n\n // Free the memory used by the lockfiles, since nothing should read the lockfile from this point on.\n PnpmShrinkwrapFile.clearCache();\n\n terminal.writeLine(`Resolver cache written.`);\n}\n"]}
|
package/lib/externals.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals.d.ts","sourceRoot":"","sources":["../src/externals.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"externals.d.ts","sourceRoot":"","sources":["../src/externals.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,eAAe,IAAI,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,KAAK,EAAE,kBAAkB,IAAI,sBAAsB,EAAE,MAAM,uDAAuD,CAAC;AAO1H,QAAA,MAAQ,SAAS,wBAAE,eAAe,4BAA4B,CAAC;AAE/D,KAAK,SAAS,GAAG,aAAa,CAAC;AAE/B,KAAK,eAAe,GAAG,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;AAmBtC,eAAO,MAAQ,kBAAkB,+BAEyB,CAAC;AAE3D,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAGxD,eAAO,MAAQ,KAAK,+DAEnB,CAAC;AACF,eAAO,MAAQ,UAAU,yEAExB,CAAC"}
|
package/lib/externals.js
CHANGED
|
@@ -8,17 +8,19 @@ exports.Operation = Operation;
|
|
|
8
8
|
exports.OperationStatus = OperationStatus;
|
|
9
9
|
// Support this plugin being webpacked.
|
|
10
10
|
const req = typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : require;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const rushLibPath = process.env._RUSH_LIB_PATH;
|
|
12
|
+
function importDependency(name) {
|
|
13
|
+
if (!rushLibPath) {
|
|
14
|
+
throw new Error(`_RUSH_LIB_PATH variable is not set, cannot resolve rush-lib.`);
|
|
15
|
+
}
|
|
14
16
|
const externalPath = req.resolve(name, {
|
|
15
|
-
paths:
|
|
17
|
+
paths: [rushLibPath]
|
|
16
18
|
});
|
|
17
19
|
return req(externalPath);
|
|
18
20
|
}
|
|
19
21
|
// Private Rush APIs
|
|
20
|
-
exports.PnpmShrinkwrapFile =
|
|
22
|
+
exports.PnpmShrinkwrapFile = importDependency('@microsoft/rush-lib/lib/logic/pnpm/PnpmShrinkwrapFile').PnpmShrinkwrapFile;
|
|
21
23
|
// Avoid bundling expensive stuff that's already part of Rush.
|
|
22
|
-
exports.Async =
|
|
23
|
-
exports.FileSystem =
|
|
24
|
+
exports.Async = importDependency(`@rushstack/node-core-library/lib/Async`).Async;
|
|
25
|
+
exports.FileSystem = importDependency(`@rushstack/node-core-library/lib/FileSystem`).FileSystem;
|
|
24
26
|
//# sourceMappingURL=externals.js.map
|
package/lib/externals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"externals.js","sourceRoot":"","sources":["../src/externals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;
|
|
1
|
+
{"version":3,"file":"externals.js","sourceRoot":"","sources":["../src/externals.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAU3D,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,uBAAuB,CAAC;AAMtD,8BAAS;AAAE,0CAAe;AAEnC,uCAAuC;AACvC,MAAM,GAAG,GAAmB,OAAO,uBAAuB,KAAK,UAAU,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,OAAO,CAAC;AAE9G,MAAM,WAAW,GAAuB,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;AAEnE,SAAS,gBAAgB,CAAU,IAAY;IAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IACD,MAAM,YAAY,GAAW,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;QAC7C,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC,YAAY,CAAC,CAAC;AAC3B,CAAC;AAED,oBAAoB;AACL,0BAAkB,GAAK,gBAAgB,CAEpD,uDAAuD,CAAC,oBAAC;AAI3D,8DAA8D;AAC/C,aAAK,GAAK,gBAAgB,CACvC,wCAAwC,CACzC,OAAC;AACa,kBAAU,GAAK,gBAAgB,CAC5C,6CAA6C,CAC9C,YAAC","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 type { Operation as OperationType, OperationStatus as OperationStatusType } from '@rushstack/rush-sdk';\nimport type { PnpmShrinkwrapFile as PnpmShrinkwrapFileType } from '@rushstack/rush-sdk/lib/logic/pnpm/PnpmShrinkwrapFile';\nimport type * as rushSdkType from '@rushstack/rush-sdk';\n\n// Ultra-cheap \"I am a Rush plugin\" import of rush-lib\n// eslint-disable-next-line @typescript-eslint/naming-convention\ndeclare const ___rush___rushLibModule: typeof rushSdkType;\n\nconst { Operation, OperationStatus } = ___rush___rushLibModule;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\ntype Operation = OperationType;\n// eslint-disable-next-line @typescript-eslint/no-redeclare\ntype OperationStatus = OperationStatusType;\n\nexport { Operation, OperationStatus };\n\n// Support this plugin being webpacked.\nconst req: typeof require = typeof __non_webpack_require__ === 'function' ? __non_webpack_require__ : require;\n\nconst rushLibPath: string | undefined = process.env._RUSH_LIB_PATH;\n\nfunction importDependency<TResult>(name: string): TResult {\n if (!rushLibPath) {\n throw new Error(`_RUSH_LIB_PATH variable is not set, cannot resolve rush-lib.`);\n }\n const externalPath: string = req.resolve(name, {\n paths: [rushLibPath]\n });\n\n return req(externalPath);\n}\n\n// Private Rush APIs\nexport const { PnpmShrinkwrapFile } = importDependency<\n typeof import('@rushstack/rush-sdk/lib/logic/pnpm/PnpmShrinkwrapFile')\n>('@microsoft/rush-lib/lib/logic/pnpm/PnpmShrinkwrapFile');\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport type PnpmShrinkwrapFile = PnpmShrinkwrapFileType;\n\n// Avoid bundling expensive stuff that's already part of Rush.\nexport const { Async } = importDependency<typeof import('@rushstack/node-core-library/lib/Async')>(\n `@rushstack/node-core-library/lib/Async`\n);\nexport const { FileSystem } = importDependency<typeof import('@rushstack/node-core-library/lib/FileSystem')>(\n `@rushstack/node-core-library/lib/FileSystem`\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/rush-resolver-cache-plugin",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.159.0",
|
|
4
4
|
"description": "A Rush plugin that generates a resolver cache file after successful install.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"main": "lib-commonjs/index.js",
|
|
12
12
|
"types": "dist/rush-resolver-cache-plugin.d.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@rushstack/rush-sdk": "5.
|
|
14
|
+
"@rushstack/rush-sdk": "5.159.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/webpack-env": "1.18.8",
|
|
18
18
|
"eslint": "~9.25.1",
|
|
19
|
-
"@rushstack/
|
|
20
|
-
"@rushstack/
|
|
21
|
-
"@rushstack/node-core-library": "5.
|
|
22
|
-
"@rushstack/terminal": "0.
|
|
23
|
-
"
|
|
24
|
-
"
|
|
19
|
+
"@rushstack/lookup-by-path": "0.8.1",
|
|
20
|
+
"@rushstack/heft": "1.0.0",
|
|
21
|
+
"@rushstack/node-core-library": "5.15.1",
|
|
22
|
+
"@rushstack/terminal": "0.18.0",
|
|
23
|
+
"@rushstack/webpack-workspace-resolve-plugin": "0.4.32",
|
|
24
|
+
"local-node-rig": "1.0.0"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|