@ms-cloudpack/package-hashes 0.3.9 → 0.3.10
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/lib/PackageHashes.js.map +1 -1
- package/lib/PackagePatchesCache.d.ts.map +1 -1
- package/lib/PackagePatchesCache.js +17 -2
- package/lib/PackagePatchesCache.js.map +1 -1
- package/lib/getInlinedDependenciesPaths.js.map +1 -1
- package/lib/getPackageHashEntries.js.map +1 -1
- package/lib/getPatchFileContent.js.map +1 -1
- package/lib/getSourceHash.js.map +1 -1
- package/lib/hashPackage.js.map +1 -1
- package/lib/parsePatchFilePath.js.map +1 -1
- package/package.json +1 -1
package/lib/PackageHashes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageHashes.js","sourceRoot":"","sources":["../src/PackageHashes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,MAAM,OAAO,aAAa;IAKxB,YAAqB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QAJjC,sBAAiB,GAAG,IAAI,GAAG,EAA+C,CAAC;QAC3E,wBAAmB,GAAG,IAAI,GAAG,EAA+C,CAAC;QAI5F,IAAI,MAAM,IAAI,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"PackageHashes.js","sourceRoot":"","sources":["../src/PackageHashes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,MAAM,OAAO,aAAa;IAKxB,YAAqB,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QAJjC,sBAAiB,GAAG,IAAI,GAAG,EAA+C,CAAC;QAC3E,wBAAmB,GAAG,IAAI,GAAG,EAA+C,CAAC;QAI5F,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;YAC1B,OAAO;QACT,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;QACnC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC;YACtC,WAAW,EAAE,MAAM,CAAC,qBAAqB;SAC1C,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG;YACd,GAAG,OAAO,CAAC,OAAO;YAClB,OAAO;SACR,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,CAAC,MAIT;QACC,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;QAE1E,MAAM,GAAG,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;QAEvF,IAAI,CAAC,iBAAiB,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/C,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAW,CAAC;QACxC,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEtC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { PackagePatchesCache } from './PackagePatchesCache.js';\nimport { hashPackage } from './hashPackage.js';\nimport type { HashFunction } from './types/HashFunctions.js';\nimport type { PackageHashesOptions } from './types/PackageHashOptions.js';\n\n/**\n * Utility class for hashing packages and caching the results.\n */\nexport class PackageHashes {\n private readonly _hashesWithSource = new Map<string /* packagePath */, string /* hash */>();\n private readonly _hashesWithNoSource = new Map<string /* packagePath */, string /* hash */>();\n private readonly _hash: HashFunction;\n\n constructor(readonly options: PackageHashesOptions) {\n if ('hash' in options) {\n this._hash = options.hash;\n return;\n }\n\n const { config } = options.context;\n const patches = new PackagePatchesCache({\n globPattern: config.patchFilesGlobPattern,\n });\n\n const context = {\n ...options.context,\n patches,\n };\n\n this._hash = (input) => hashPackage({ input, context });\n }\n\n /**\n * Gets the hash for a given package path. This is useful for caching, to determine if the package has changed.\n * If the package definition has not been calculated, it will be calculated and cached.\n * @param packagePath - The package path to get the hash for.\n * @param isSourceHashingEnabled - Whether or not to hash the source files.\n * @param shouldRecalculate - Whether or not to force a re-calculation of the hash.\n * @returns The hash for the package.\n */\n async get(params: {\n packagePath: string;\n isSourceHashingEnabled: boolean;\n shouldRecalculate?: boolean;\n }): Promise<string> {\n const { packagePath, isSourceHashingEnabled, shouldRecalculate } = params;\n\n const map = isSourceHashingEnabled ? this._hashesWithSource : this._hashesWithNoSource;\n\n if (!shouldRecalculate && map.has(packagePath)) {\n return map.get(packagePath) as string;\n }\n\n const hash = await this._hash(params);\n\n map.set(packagePath, hash);\n\n return hash;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackagePatchesCache.d.ts","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"PackagePatchesCache.d.ts","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAaD;;;;;;;;GAQG;AACH,qBAAa,mBAAoB,YAAW,cAAc;IAG5C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAmG;gBAEtF,QAAQ,EAAE,sBAAsB;IAE7D,OAAO,CAAC,MAAM;IAId;;OAEG;YACW,mBAAmB;IAgCjC;;;;;OAKG;IACU,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMlE"}
|
|
@@ -2,6 +2,17 @@ import { parsePatchFilePath } from './parsePatchFilePath.js';
|
|
|
2
2
|
import glob from 'fast-glob';
|
|
3
3
|
import { findGitRoot } from 'workspace-tools';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
/**
|
|
6
|
+
* Gets the root path of the repo. If the repo is not a git repo, it will return undefined.
|
|
7
|
+
*/
|
|
8
|
+
function getGitRepoPathSafe(currentPath) {
|
|
9
|
+
try {
|
|
10
|
+
return findGitRoot(currentPath);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
/**
|
|
6
17
|
* PackagePatchesCache is a class responsible for managing a cache of patched packages
|
|
7
18
|
* by reading and storing information about patch files in the patches folder at the root of the repo.
|
|
@@ -22,10 +33,14 @@ export class PackagePatchesCache {
|
|
|
22
33
|
* Loads the list of patched packages from the patches folder.
|
|
23
34
|
*/
|
|
24
35
|
async loadPatchedPackages() {
|
|
36
|
+
this._patches = {};
|
|
25
37
|
// get the repo root
|
|
26
|
-
const rootPath = this.settings.globRootPath ||
|
|
38
|
+
const rootPath = this.settings.globRootPath || getGitRepoPathSafe(process.cwd());
|
|
39
|
+
if (!rootPath) {
|
|
40
|
+
console.info('Could not find the root of the repo. Skipping loading patched packages.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
27
43
|
// get the files with .patch extension
|
|
28
|
-
this._patches = {};
|
|
29
44
|
const patchFiles = await glob(this.settings.globPattern || 'patches/*.patch', {
|
|
30
45
|
cwd: rootPath,
|
|
31
46
|
absolute: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackagePatchesCache.js","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AAOxB;;;;;;;;GAQG;AACH,MAAM,OAAO,mBAAmB;IAG9B,YAA6B,QAAgC;QAAhC,aAAQ,GAAR,QAAQ,CAAwB;IAAG,CAAC;IAEzD,MAAM,CAAC,WAAmB,EAAE,OAAe;QACjD,OAAO,GAAG,WAAW,IAAI,OAAO,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,mBAAmB;QAC/B,oBAAoB;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,
|
|
1
|
+
{"version":3,"file":"PackagePatchesCache.js","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,IAAI,MAAM,MAAM,CAAC;AAOxB;;GAEG;AACH,SAAS,kBAAkB,CAAC,WAAmB;IAC7C,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;G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CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,WAAmB,EAAE,OAAe;QAC/D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["import { parsePatchFilePath } from './parsePatchFilePath.js';\nimport glob from 'fast-glob';\nimport type { PackagePatches } from './types/PackagePatches.js';\nimport { findGitRoot } from 'workspace-tools';\nimport path from 'path';\n\nexport interface PackagePatchesSettings {\n globRootPath?: string;\n globPattern?: string;\n}\n\n/**\n * Gets the root path of the repo. If the repo is not a git repo, it will return undefined.\n */\nfunction getGitRepoPathSafe(currentPath: string) {\n try {\n return findGitRoot(currentPath);\n } catch {\n return undefined;\n }\n}\n\n/**\n * PackagePatchesCache is a class responsible for managing a cache of patched packages\n * by reading and storing information about patch files in the patches folder at the root of the repo.\n * It provides a method to retrieve the path to the patch file for a given package\n * based on the package name and version.\n *\n * @class PackagePatchesCache\n * @implements {PackagePatches}\n */\nexport class PackagePatchesCache implements PackagePatches {\n private _patches: Record<`${string}@${string}` /* ${packageName}@${version} */, string /* filePath */> | undefined;\n\n constructor(private readonly settings: PackagePatchesSettings) {}\n\n private getKey(packageName: string, version: string): `${string}@${string}` {\n return `${packageName}@${version}`;\n }\n\n /**\n * Loads the list of patched packages from the patches folder.\n */\n private async loadPatchedPackages() {\n this._patches = {};\n\n // get the repo root\n const rootPath = this.settings.globRootPath || getGitRepoPathSafe(process.cwd());\n\n if (!rootPath) {\n console.info('Could not find the root of the repo. Skipping loading patched packages.');\n return;\n }\n\n // get the files with .patch extension\n const patchFiles = await glob(this.settings.globPattern || 'patches/*.patch', {\n cwd: rootPath,\n absolute: true,\n });\n\n for (const absoluteFilePath of patchFiles) {\n try {\n const normalizedPath = path.normalize(absoluteFilePath);\n\n const { packageName, version } = parsePatchFilePath(normalizedPath);\n\n console.debug(`Found patch file for package: ${packageName}@${version}`);\n\n this._patches[this.getKey(packageName, version)] = normalizedPath;\n } catch (e) {\n console.warn(`Invalid patch file: ${absoluteFilePath}`);\n }\n }\n }\n\n /**\n * Gets the path to the patch file for the specified package.\n * @param packageName - The name of the package to check.\n * @param version - The version of the package to check.\n * @returns - Path to the patch file if the package has been patched, undefined otherwise.\n */\n public async getPackagePatch(packageName: string, version: string) {\n if (!this._patches) {\n await this.loadPatchedPackages();\n }\n return this._patches?.[this.getKey(packageName, version)];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInlinedDependenciesPaths.js","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,iCAAiC,CAAC;AAGvF,MAAM,UAAU,2BAA2B,CAAC,MAS3C;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEhD,MAAM,mBAAmB,GAAG;QAC1B,GAAG,CAAC,eAAe,CAAC,mBAAmB,EAAE,mBAAmB,IAAI,EAAE,CAAC;QACnE,GAAG,CAAC,eAAe,CAAC,wBAAwB,EAAE,mBAAmB,IAAI,EAAE,CAAC;KACzE,CAAC;IAEF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACtE,mBAAmB,CAAC;QAClB,WAAW,EAAE,UAAU;QACvB,UAAU;QACV,UAAU;KACX,CAAC,CACH,CAAC;IAEF,KAAK,MAAM,sBAAsB,IAAI,wBAAwB,EAAE;
|
|
1
|
+
{"version":3,"file":"getInlinedDependenciesPaths.js","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,iCAAiC,CAAC;AAGvF,MAAM,UAAU,2BAA2B,CAAC,MAS3C;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAEhD,MAAM,mBAAmB,GAAG;QAC1B,GAAG,CAAC,eAAe,CAAC,mBAAmB,EAAE,mBAAmB,IAAI,EAAE,CAAC;QACnE,GAAG,CAAC,eAAe,CAAC,wBAAwB,EAAE,mBAAmB,IAAI,EAAE,CAAC;KACzE,CAAC;IAEF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACtE,mBAAmB,CAAC;QAClB,WAAW,EAAE,UAAU;QACvB,UAAU;QACV,UAAU;KACX,CAAC,CACH,CAAC;IAEF,KAAK,MAAM,sBAAsB,IAAI,wBAAwB,EAAE,CAAC;QAC9D,IAAI,sBAAsB,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/config-types';\nimport { findResolveMapEntry, type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport type { getPackageSettings } from '@ms-cloudpack/config';\n\nexport function getInlinedDependenciesPaths(params: {\n options: {\n packageName: string;\n definition: PackageJson;\n };\n context: {\n resolveMap: ResolveMap;\n packageSettings: ReturnType<typeof getPackageSettings>;\n };\n}) {\n const { options, context } = params;\n const { definition } = options;\n const { resolveMap, packageSettings } = context;\n\n const inlinedDependencies = [\n ...(packageSettings.userPackageSettings?.inlinedDependencies || []),\n ...(packageSettings.generatedPackageSettings?.inlinedDependencies || []),\n ];\n\n const result: string[] = [];\n const inlinedDependencyEntries = inlinedDependencies.map((dependency) =>\n findResolveMapEntry({\n packageName: dependency,\n resolveMap,\n definition,\n }),\n );\n\n for (const inlinedDependencyEntry of inlinedDependencyEntries) {\n if (inlinedDependencyEntry) {\n result.push(inlinedDependencyEntry.path);\n }\n }\n\n return result;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageHashEntries.js","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAU3C;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE9C,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"getPackageHashEntries.js","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE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S,CAAC;IAEpG,OAAO;QACL,GAAG,UAAU;QACb,IAAI;QACJ,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW;QAC3C,SAAS;QACT,gBAAgB;QAChB,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { getSourceHash } from './getSourceHash.js';\nimport { getPackageSettings } from '@ms-cloudpack/config';\nimport type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport type { PackagePatches } from './types/PackagePatches.js';\nimport { getPatchFileContent } from './getPatchFileContent.js';\n\n/**\n * @returns the entries that are used to calculate the hash of a package\n */\nexport async function getPackageHashEntries(params: {\n options: {\n packagePath: string;\n isSourceHashingEnabled: boolean;\n };\n context: {\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n patches: PackagePatches;\n };\n}) {\n const { options, context } = params;\n const { packagePath, isSourceHashingEnabled } = options;\n const { packages, config, patches } = context;\n\n const definition = await packages.get(packagePath);\n\n if (!definition) {\n throw new Error(`Package definition (package.json) missing or invalid at \"${packagePath}\"`);\n }\n\n const { name, version } = definition;\n if (!name) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n if (!version) {\n throw new Error(`Package definition (package.json) missing version at \"${packagePath}\"`);\n }\n\n const isExternal = isExternalPackage(packagePath);\n\n const packageSettings = getPackageSettings({ name, version, config });\n\n const filesHash =\n !isExternal && isSourceHashingEnabled ? await getSourceHash({ packagePath, packageSettings }) : undefined;\n\n const patchFileContent = isExternal ? await getPatchFileContent(patches, name, version) : undefined;\n\n return {\n ...definition,\n name,\n version: isExternal ? version : packagePath,\n filesHash,\n patchFileContent,\n packageSettings,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPatchFileContent.js","sourceRoot":"","sources":["../src/getPatchFileContent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAuB,EAAE,WAAmB,EAAE,OAAe;IACrG,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAE1E,IAAI,CAAC,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"getPatchFileContent.js","sourceRoot":"","sources":["../src/getPatchFileContent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAuB,EAAE,WAAmB,EAAE,OAAe;IACrG,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAE1E,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE7D,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import type { PackagePatches } from './types/PackagePatches.js';\nimport { readFile } from 'fs/promises';\n\n/**\n * Finds a .patch file for a package and returns its hash.\n * @param packageName - the name of the package\n * @param version - the version of the package\n * @returns the hash of the .patch file for the package, or undefined if no .patch file exists\n */\nexport async function getPatchFileContent(patches: PackagePatches, packageName: string, version: string) {\n const patchFilePath = await patches.getPackagePatch(packageName, version);\n\n if (!patchFilePath) {\n return undefined;\n }\n\n const patchFileHash = await readFile(patchFilePath, 'utf-8');\n\n return patchFileHash;\n}\n"]}
|
package/lib/getSourceHash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSourceHash.js","sourceRoot":"","sources":["../src/getSourceHash.ts"],"names":[],"mappings":"AACA,OAAO,I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AAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QACrD,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE;QACjC,GAAG,EAAE,WAAW;KACjB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAEnD,OAAO,CAAC,KAAK,CAAC,0BAA0B,WAAW,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IAEzF,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { PackageSettings } from '@ms-cloudpack/config-types';\nimport glob from 'fast-glob';\nimport { existsSync } from 'fs';\nimport { hash } from 'glob-hasher';\nimport path from 'path';\n\nconst excludeNodeModules = '!**/node_modules/**';\n\n/**\n * Get the hash of the source files in a package\n * If there is a src folder, hash the files in that folder, the .*json files and the inputPaths\n * If there are inputPaths, hash those files in addition to the .*json files\n * Otherwise, hash all files except node_modules\n */\nexport async function getSourceHash(options: {\n packagePath: string;\n packageSettings?: {\n userPackageSettings: PackageSettings | undefined;\n generatedPackageSettings: PackageSettings | undefined;\n };\n}) {\n const start = performance.now();\n\n const { packagePath, packageSettings } = options;\n const inputPaths = packageSettings?.userPackageSettings?.inputPaths;\n // Use the inputPaths if they are defined, otherwise use the src folder if it exists\n // Otherwise, use all files except node_modules\n let patterns: string[];\n if (inputPaths?.length) {\n patterns = inputPaths;\n } else if (existsSync(path.join(packagePath, 'src'))) {\n patterns = ['src/**', '*.json', excludeNodeModules];\n } else {\n patterns = ['**', excludeNodeModules];\n }\n\n const files = await glob(patterns, {\n cwd: packagePath,\n });\n\n const globHash = hash(files, { cwd: packagePath });\n\n console.debug(`Hashed source files in ${packagePath} in ${performance.now() - start}ms`);\n\n return globHash;\n}\n"]}
|
package/lib/hashPackage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashPackage.js","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,MAAM,iCAAiC,CAAC;AAClE,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAG/E,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAWjC;IACC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAClC,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC1D,MAAM,gBAAgB,GAAwD,EAAE,CAAC;IACjF,MAAM,cAAc,GAAa,CAAC,WAAW,CAAC,CAAC;IAE/C,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"hashPackage.js","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,MAAM,iCAAiC,CAAC;AAClE,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAG/E,IAAI,SAAS,GAAG,CAA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AAgB,EAAE;QAC9C,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,IAAI;QACrB,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC9C,SAAS,IAAI,WAAW,CAAC;IACzB,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,OAAO,OAAO,WAAW,mBAAmB,SAAS,IAAI,CAAC,CAAC;IAE3F,OAAO,IAAI,WAAW,IAAI,UAAU,EAAE,CAAC;AACzC,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport objectHash from 'object-hash';\nimport { getPackageHashEntries } from './getPackageHashEntries.js';\nimport type { CloudpackConfig } from '@ms-cloudpack/config-types';\nimport { getInlinedDependenciesPaths } from './getInlinedDependenciesPaths.js';\nimport type { PackagePatches } from './types/PackagePatches.js';\n\nlet totalTime = 0;\n\n/**\n * Hash version is used to invalidate the cache when the hashing algorithm changes.\n */\nconst hashVersion = 2;\n\nexport async function hashPackage(params: {\n input: {\n packagePath: string;\n isSourceHashingEnabled: boolean;\n };\n context: {\n packages: PackageDefinitionsCache;\n config: CloudpackConfig;\n resolveMap: ResolveMap;\n patches: PackagePatches;\n };\n}): Promise<string> {\n const start = performance.now();\n const { input, context } = params;\n const { packagePath, isSourceHashingEnabled } = input;\n const { resolveMap, config, packages, patches } = context;\n const hashEntriesArray: Awaited<ReturnType<typeof getPackageHashEntries>>[] = [];\n const packagesToHash: string[] = [packagePath];\n\n while (packagesToHash.length > 0) {\n const packageToHash = packagesToHash.pop();\n if (!packageToHash) {\n continue;\n }\n\n const hashEntries = await getPackageHashEntries({\n options: { isSourceHashingEnabled, packagePath: packageToHash },\n context: { packages, config, patches },\n });\n\n hashEntriesArray.push(hashEntries);\n\n if (config) {\n const inlinedDependenciesPaths = getInlinedDependenciesPaths({\n options: {\n packageName: hashEntries.name,\n definition: hashEntries,\n },\n context: { packageSettings: hashEntries.packageSettings, resolveMap },\n });\n packagesToHash.push(...inlinedDependenciesPaths);\n }\n }\n\n const hashResult = objectHash(hashEntriesArray, {\n respectType: false,\n unorderedArrays: true,\n unorderedSets: true,\n unorderedObjects: true,\n ignoreUnknown: true,\n });\n\n const { name, version } = hashEntriesArray[0];\n const elapsedTime = performance.now() - start;\n totalTime += elapsedTime;\n console.debug(`Hashed ${name}@${version} in ${elapsedTime}ms, total time: ${totalTime}ms`);\n\n return `v${hashVersion}-${hashResult}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsePatchFilePath.js","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEzC,uCAAuC;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElF,qEAAqE;IACrE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"parsePatchFilePath.js","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAEzC,uCAAuC;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAElF,qEAAqE;IACrE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,qEAAqE,CAC1G,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE/D,8BAA8B;IAC9B,MAAM,MAAM,GAAG;QACb,WAAW;QACX,OAAO;KACR,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path from 'path';\n\n/**\n * Parses a patch file name and returns the package name and version\n * @param filePath - The path of the patch file (e.g. users/test/repo/my-repo/patches/@fluentui+react-combobox+9.5.28.patch)\n * @returns An object with the package name and version (e.g. { packageName: '@fluentui/react-combobox', version: '9.5.28' })\n */\nexport function parsePatchFilePath(filePath: string): { packageName: string; version: string } {\n const fileName = path.basename(filePath);\n\n // Split the packageString based on '+'\n const parts = fileName.substring(0, fileName.length - '.patch'.length).split('+');\n\n // If the parts array doesn't have the expected length throw an error\n if (parts.length < 2) {\n throw new Error(\n `Invalid patch file name: ${fileName}, it should contains both package name and version separated by '+'`,\n );\n }\n\n // Extract the packageName, version, and patch\n const version = parts[parts.length - 1];\n const packageName = parts.slice(0, parts.length - 1).join('/');\n\n // Construct the result object\n const result = {\n packageName,\n version,\n };\n\n return result;\n}\n"]}
|