@ms-cloudpack/package-hashes 0.2.3 → 0.2.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PackageHashes.d.ts","sourceRoot":"","sources":["../src/PackageHashes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;GAEG;AACH,qBAAa,aAAa;IAKZ,QAAQ,CAAC,OAAO,EAAE,oBAAoB;IAJlD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0D;IAC5F,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA0D;IAC9F,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAEhB,OAAO,EAAE,oBAAoB;IAIlD;;;;;;;OAOG;IACG,GAAG,CAAC,MAAM,EAAE;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,sBAAsB,EAAE,OAAO,CAAC;QAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,GAAG,OAAO,CAAC,MAAM,CAAC;CAepB"}
1
+ {"version":3,"file":"PackageHashes.d.ts","sourceRoot":"","sources":["../src/PackageHashes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;GAEG;AACH,qBAAa,aAAa;IAKZ,QAAQ,CAAC,OAAO,EAAE,oBAAoB;IAJlD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0D;IAC5F,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA0D;IAC9F,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;gBAEhB,OAAO,EAAE,oBAAoB;IAmBlD;;;;;;;OAOG;IACG,GAAG,CAAC,MAAM,EAAE;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,sBAAsB,EAAE,OAAO,CAAC;QAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,GAAG,OAAO,CAAC,MAAM,CAAC;CAepB"}
@@ -1,3 +1,4 @@
1
+ import { PackagePatchesCache } from './PackagePatchesCache.js';
1
2
  import { hashPackage } from './hashPackage.js';
2
3
  /**
3
4
  * Utility class for hashing packages and caching the results.
@@ -7,7 +8,19 @@ export class PackageHashes {
7
8
  this.options = options;
8
9
  this._hashesWithSource = new Map();
9
10
  this._hashesWithNoSource = new Map();
10
- this._hash = 'hash' in options ? options.hash : (input) => hashPackage({ input, context: options.context });
11
+ if ('hash' in options) {
12
+ this._hash = options.hash;
13
+ return;
14
+ }
15
+ const { config } = options.context;
16
+ const patches = new PackagePatchesCache({
17
+ globPattern: config.patchFilesGlobPattern,
18
+ });
19
+ const context = {
20
+ ...options.context,
21
+ patches,
22
+ };
23
+ this._hash = (input) => hashPackage({ input, context });
11
24
  }
12
25
  /**
13
26
  * Gets the hash for a given package path. This is useful for caching, to determine if the package has changed.
@@ -1 +1 @@
1
- {"version":3,"file":"PackageHashes.js","sourceRoot":"","sources":["../src/PackageHashes.ts"],"names":[],"mappings":"AAAA,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,CAAC,KAAK,GAAG,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9G,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;YAC9C,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAW,CAAC;SACvC;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 { 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 this._hash = 'hash' in options ? options.hash : (input) => hashPackage({ input, context: options.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(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AW,CAAW,CAAC;SACvC;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"]}
@@ -0,0 +1,32 @@
1
+ import type { PackagePatches } from './types/PackagePatches.js';
2
+ export interface PackagePatchesSettings {
3
+ globRootPath?: string;
4
+ globPattern?: string;
5
+ }
6
+ /**
7
+ * PackagePatchesCache is a class responsible for managing a cache of patched packages
8
+ * by reading and storing information about patch files in the patches folder at the root of the repo.
9
+ * It provides a method to retrieve the path to the patch file for a given package
10
+ * based on the package name and version.
11
+ *
12
+ * @class PackagePatchesCache
13
+ * @implements {PackagePatches}
14
+ */
15
+ export declare class PackagePatchesCache implements PackagePatches {
16
+ private readonly settings;
17
+ private _patches;
18
+ constructor(settings: PackagePatchesSettings);
19
+ private getKey;
20
+ /**
21
+ * Loads the list of patched packages from the patches folder.
22
+ */
23
+ private loadPatchedPackages;
24
+ /**
25
+ * Gets the path to the patch file for the specified package.
26
+ * @param packageName - The name of the package to check.
27
+ * @param version - The version of the package to check.
28
+ * @returns - Path to the patch file if the package has been patched, undefined otherwise.
29
+ */
30
+ getPackagePatch(packageName: string, version: string): Promise<string | undefined>;
31
+ }
32
+ //# sourceMappingURL=PackagePatchesCache.d.ts.map
@@ -0,0 +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;AAED;;;;;;;;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;IA2BjC;;;;;OAKG;IACU,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMlE"}
@@ -0,0 +1,58 @@
1
+ import { parsePatchFilePath } from './parsePatchFilePath.js';
2
+ import glob from 'fast-glob';
3
+ import { findGitRoot } from 'workspace-tools';
4
+ import path from 'path';
5
+ /**
6
+ * PackagePatchesCache is a class responsible for managing a cache of patched packages
7
+ * by reading and storing information about patch files in the patches folder at the root of the repo.
8
+ * It provides a method to retrieve the path to the patch file for a given package
9
+ * based on the package name and version.
10
+ *
11
+ * @class PackagePatchesCache
12
+ * @implements {PackagePatches}
13
+ */
14
+ export class PackagePatchesCache {
15
+ constructor(settings) {
16
+ this.settings = settings;
17
+ }
18
+ getKey(packageName, version) {
19
+ return `${packageName}@${version}`;
20
+ }
21
+ /**
22
+ * Loads the list of patched packages from the patches folder.
23
+ */
24
+ async loadPatchedPackages() {
25
+ // get the repo root
26
+ const rootPath = this.settings.globRootPath || findGitRoot(process.cwd());
27
+ // get the files with .patch extension
28
+ this._patches = {};
29
+ const patchFiles = await glob(this.settings.globPattern || 'patches/*.patch', {
30
+ cwd: rootPath,
31
+ absolute: true,
32
+ });
33
+ for (const absoluteFilePath of patchFiles) {
34
+ try {
35
+ const normalizedPath = path.normalize(absoluteFilePath);
36
+ const { packageName, version } = parsePatchFilePath(normalizedPath);
37
+ console.debug(`Found patch file for package: ${packageName}@${version}`);
38
+ this._patches[this.getKey(packageName, version)] = normalizedPath;
39
+ }
40
+ catch (e) {
41
+ console.warn(`Invalid patch file: ${absoluteFilePath}`);
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Gets the path to the patch file for the specified package.
47
+ * @param packageName - The name of the package to check.
48
+ * @param version - The version of the package to check.
49
+ * @returns - Path to the patch file if the package has been patched, undefined otherwise.
50
+ */
51
+ async getPackagePatch(packageName, version) {
52
+ if (!this._patches) {
53
+ await this.loadPatchedPackages();
54
+ }
55
+ return this._patches?.[this.getKey(packageName, version)];
56
+ }
57
+ }
58
+ //# sourceMappingURL=PackagePatchesCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackagePatchesCache.js","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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E,CAAC,CAAC;aACzD;SACF;IACH,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,WAAmB,EAAE,OAAe;QAC/D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;SAClC;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 * 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 // get the repo root\n const rootPath = this.settings.globRootPath || findGitRoot(process.cwd());\n\n // get the files with .patch extension\n this._patches = {};\n\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,5 +1,6 @@
1
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
2
  import type { CloudpackConfig } from '@ms-cloudpack/config-types';
3
+ import type { PackagePatches } from './types/PackagePatches.js';
3
4
  /**
4
5
  * @returns the entries that are used to calculate the hash of a package
5
6
  */
@@ -11,11 +12,13 @@ export declare function getPackageHashEntries(params: {
11
12
  context: {
12
13
  config: CloudpackConfig;
13
14
  packages: PackageDefinitionsCache;
15
+ patches: PackagePatches;
14
16
  };
15
17
  }): Promise<{
16
18
  name: string;
17
19
  version: string;
18
20
  filesHash: Record<string, string> | null | undefined;
21
+ patchFileContent: string | undefined;
19
22
  packageSettings: {
20
23
  userPackageSettings: import("@ms-cloudpack/config-types").PackageSettings | undefined;
21
24
  generatedPackageSettings: import("@ms-cloudpack/config-types").PackageSettings | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"getPackageHashEntries.d.ts","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAI3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,sBAAsB,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,MAAM,EAAE,eAAe,CAAC;QACxB,QAAQ,EAAE,uBAAuB,CAAC;KACnC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCA"}
1
+ {"version":3,"file":"getPackageHashEntries.d.ts","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAI3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,sBAAsB,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,MAAM,EAAE,eAAe,CAAC;QACxB,QAAQ,EAAE,uBAAuB,CAAC;QAClC,OAAO,EAAE,cAAc,CAAC;KACzB,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCA"}
@@ -1,13 +1,14 @@
1
1
  import { isExternalPackage } from '@ms-cloudpack/package-utilities';
2
2
  import { getSourceHash } from './getSourceHash.js';
3
3
  import { getPackageSettings } from '@ms-cloudpack/config';
4
+ import { getPatchFileContent } from './getPatchFileContent.js';
4
5
  /**
5
6
  * @returns the entries that are used to calculate the hash of a package
6
7
  */
7
8
  export async function getPackageHashEntries(params) {
8
9
  const { options, context } = params;
9
10
  const { packagePath, isSourceHashingEnabled } = options;
10
- const { packages, config } = context;
11
+ const { packages, config, patches } = context;
11
12
  const definition = await packages.get(packagePath);
12
13
  if (!definition) {
13
14
  throw new Error(`Package definition (package.json) missing or invalid at "${packagePath}"`);
@@ -22,11 +23,13 @@ export async function getPackageHashEntries(params) {
22
23
  const isExternal = isExternalPackage(packagePath);
23
24
  const packageSettings = getPackageSettings({ name, version, config });
24
25
  const filesHash = !isExternal && isSourceHashingEnabled ? await getSourceHash({ packagePath, packageSettings }) : undefined;
26
+ const patchFileContent = isExternal ? await getPatchFileContent(patches, name, version) : undefined;
25
27
  return {
26
28
  ...definition,
27
29
  name,
28
30
  version: isExternal ? version : packagePath,
29
31
  filesHash,
32
+ patchFileContent,
30
33
  packageSettings,
31
34
  };
32
35
  }
@@ -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;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAS3C;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,GAAG,OAAO,CAAC;IAErC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,4DAA4D,WAAW,GAAG,CAAC,CAAC;KAC7F;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IACrC,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,WAAW,GAAG,CAAC,CAAC;KACvF;IACD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,yDAAyD,WAAW,GAAG,CAAC,CAAC;KAC1F;IAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAElD,MAAM,eAAe,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtE,MAAM,SAAS,GACb,CAAC,UAAU,IAAI,sBAAsB,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE5G,OAAO;QACL,GAAG,UAAU;QACb,IAAI;QACJ,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW;QAC3C,SAAS;QACT,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';\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 };\n}) {\n const { options, context } = params;\n const { packagePath, isSourceHashingEnabled } = options;\n const { packages, config } = 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 return {\n ...definition,\n name,\n version: isExternal ? version : packagePath,\n filesHash,\n packageSettings,\n };\n}\n"]}
1
+ {"version":3,"file":"getPackageHashEntries.js","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"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,GAAG,UAAU,CAAC,CAAC,CAAC,MAAM,mBAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,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"]}
@@ -0,0 +1,9 @@
1
+ import type { PackagePatches } from './types/PackagePatches.js';
2
+ /**
3
+ * Finds a .patch file for a package and returns its hash.
4
+ * @param packageName - the name of the package
5
+ * @param version - the version of the package
6
+ * @returns the hash of the .patch file for the package, or undefined if no .patch file exists
7
+ */
8
+ export declare function getPatchFileContent(patches: PackagePatches, packageName: string, version: string): Promise<string | undefined>;
9
+ //# sourceMappingURL=getPatchFileContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPatchFileContent.d.ts","sourceRoot":"","sources":["../src/getPatchFileContent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,+BAUtG"}
@@ -0,0 +1,16 @@
1
+ import { readFile } from 'fs/promises';
2
+ /**
3
+ * Finds a .patch file for a package and returns its hash.
4
+ * @param packageName - the name of the package
5
+ * @param version - the version of the package
6
+ * @returns the hash of the .patch file for the package, or undefined if no .patch file exists
7
+ */
8
+ export async function getPatchFileContent(patches, packageName, version) {
9
+ const patchFilePath = await patches.getPackagePatch(packageName, version);
10
+ if (!patchFilePath) {
11
+ return undefined;
12
+ }
13
+ const patchFileHash = await readFile(patchFilePath, 'utf-8');
14
+ return patchFileHash;
15
+ }
16
+ //# sourceMappingURL=getPatchFileContent.js.map
@@ -0,0 +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;QAClB,OAAO,SAAS,CAAC;KAClB;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"]}
@@ -1,6 +1,7 @@
1
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
2
  import { type ResolveMap } from '@ms-cloudpack/package-utilities';
3
3
  import type { CloudpackConfig } from '@ms-cloudpack/config-types';
4
+ import type { PackagePatches } from './types/PackagePatches.js';
4
5
  export declare function hashPackage(params: {
5
6
  input: {
6
7
  packagePath: string;
@@ -10,6 +11,7 @@ export declare function hashPackage(params: {
10
11
  packages: PackageDefinitionsCache;
11
12
  config: CloudpackConfig;
12
13
  resolveMap: ResolveMap;
14
+ patches: PackagePatches;
13
15
  };
14
16
  }): Promise<string>;
15
17
  //# sourceMappingURL=hashPackage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashPackage.d.ts","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOlE,wBAAsB,WAAW,CAAC,MAAM,EAAE;IACxC,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,sBAAsB,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,uBAAuB,CAAC;QAClC,MAAM,EAAE,eAAe,CAAC;QACxB,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;CACH,GAAG,OAAO,CAAC,MAAM,CAAC,CAyClB"}
1
+ {"version":3,"file":"hashPackage.d.ts","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,wBAAsB,WAAW,CAAC,MAAM,EAAE;IACxC,KAAK,EAAE;QACL,WAAW,EAAE,MAAM,CAAC;QACpB,sBAAsB,EAAE,OAAO,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,uBAAuB,CAAC;QAClC,MAAM,EAAE,eAAe,CAAC;QACxB,UAAU,EAAE,UAAU,CAAC;QACvB,OAAO,EAAE,cAAc,CAAC;KACzB,CAAC;CACH,GAAG,OAAO,CAAC,MAAM,CAAC,CAyClB"}
@@ -3,12 +3,15 @@ import objectHash from 'object-hash';
3
3
  import { getPackageHashEntries } from './getPackageHashEntries.js';
4
4
  import { getInlinedDependenciesPaths } from './getInlinedDependenciesPaths.js';
5
5
  let totalTime = 0;
6
- const hashVersion = 0;
6
+ /**
7
+ * Hash version is used to invalidate the cache when the hashing algorithm changes.
8
+ */
9
+ const hashVersion = 1;
7
10
  export async function hashPackage(params) {
8
11
  const start = performance.now();
9
12
  const { input, context } = params;
10
13
  const { packagePath, isSourceHashingEnabled } = input;
11
- const { resolveMap, config, packages } = context;
14
+ const { resolveMap, config, packages, patches } = context;
12
15
  const hashEntriesArray = [];
13
16
  const packagesToHash = [packagePath];
14
17
  while (packagesToHash.length > 0) {
@@ -18,7 +21,7 @@ export async function hashPackage(params) {
18
21
  }
19
22
  const hashEntries = await getPackageHashEntries({
20
23
  options: { isSourceHashingEnabled, packagePath: packageToHash },
21
- context: { packages, config },
24
+ context: { packages, config, patches },
22
25
  });
23
26
  hashEntriesArray.push(hashEntries);
24
27
  if (config) {
@@ -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;AAE/E,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAUjC;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,GAAG,OAAO,CAAC;IACjD,MAAM,gBAAgB,GAAwD,EAAE,CAAC;IACjF,MAAM,cAAc,GAAa,CAAC,WAAW,CAAC,CAAC;IAE/C,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAChC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,aAAa,EAAE;YAClB,SAAS;SACV;QAED,MAAM,WAAW,GAAG,MAAM,qBAAqB,CAAC;YAC9C,OAAO,EAAE,EAAE,sBAAsB,EAAE,WAAW,EAAE,aAAa,EAAE;YAC/D,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;SAC9B,CAAC,CAAC;QAEH,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEnC,IAAI,MAAM,EAAE;YACV,MAAM,wBAAwB,GAAG,2BAA2B,CAAC;gBAC3D,OAAO,EAAE;oBACP,WAAW,EAAE,WAAW,CAAC,IAAI;oBAC7B,UAAU,EAAE,WAAW;iBACxB;gBACD,OAAO,EAAE,EAAE,eAAe,EAAE,WAAW,CAAC,eAAe,EAAE,UAAU,EAAE;aACtE,CAAC,CAAC;YACH,cAAc,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,CAAC;SAClD;KACF;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAEhD,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';\n\nlet totalTime = 0;\n\nconst hashVersion = 0;\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 };\n}): Promise<string> {\n const start = performance.now();\n const { input, context } = params;\n const { packagePath, isSourceHashingEnabled } = input;\n const { resolveMap, config, packages } = 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 },\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\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
+ {"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,MAA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BAAmB,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 = 1;\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\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"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parses a patch file name and returns the package name and version
3
+ * @param filePath - The path of the patch file (e.g. users/test/repo/my-repo/patches/@fluentui+react-combobox+9.5.28.patch)
4
+ * @returns An object with the package name and version (e.g. { packageName: '@fluentui/react-combobox', version: '9.5.28' })
5
+ */
6
+ export declare function parsePatchFilePath(filePath: string): {
7
+ packageName: string;
8
+ version: string;
9
+ };
10
+ //# sourceMappingURL=parsePatchFilePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsePatchFilePath.d.ts","sourceRoot":"","sources":["../src/parsePatchFilePath.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAwB7F"}
@@ -0,0 +1,25 @@
1
+ import path from 'path';
2
+ /**
3
+ * Parses a patch file name and returns the package name and version
4
+ * @param filePath - The path of the patch file (e.g. users/test/repo/my-repo/patches/@fluentui+react-combobox+9.5.28.patch)
5
+ * @returns An object with the package name and version (e.g. { packageName: '@fluentui/react-combobox', version: '9.5.28' })
6
+ */
7
+ export function parsePatchFilePath(filePath) {
8
+ const fileName = path.basename(filePath);
9
+ // Split the packageString based on '+'
10
+ const parts = fileName.substring(0, fileName.length - '.patch'.length).split('+');
11
+ // If the parts array doesn't have the expected length throw an error
12
+ if (parts.length < 2) {
13
+ throw new Error(`Invalid patch file name: ${fileName}, it should contains both package name and version separated by '+'`);
14
+ }
15
+ // Extract the packageName, version, and patch
16
+ const version = parts[parts.length - 1];
17
+ const packageName = parts.slice(0, parts.length - 1).join('/');
18
+ // Construct the result object
19
+ const result = {
20
+ packageName,
21
+ version,
22
+ };
23
+ return result;
24
+ }
25
+ //# sourceMappingURL=parsePatchFilePath.js.map
@@ -0,0 +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;QACpB,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,qEAAqE,CAC1G,CAAC;KACH;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"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.38.1"
8
+ "packageVersion": "7.38.3"
9
9
  }
10
10
  ]
11
11
  }
@@ -0,0 +1,4 @@
1
+ export interface PackagePatches {
2
+ getPackagePatch(packageName: string, version: string): Promise<string | undefined>;
3
+ }
4
+ //# sourceMappingURL=PackagePatches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackagePatches.d.ts","sourceRoot":"","sources":["../../src/types/PackagePatches.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACpF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PackagePatches.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackagePatches.js","sourceRoot":"","sources":["../../src/types/PackagePatches.ts"],"names":[],"mappings":"","sourcesContent":["export interface PackagePatches {\n getPackagePatch(packageName: string, version: string): Promise<string | undefined>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-hashes",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Utilities for hashing packages.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,13 +14,14 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/bundler-types": "^0.23.0",
18
- "@ms-cloudpack/package-utilities": "^5.6.0",
19
- "@ms-cloudpack/config": "^0.17.2",
20
- "@ms-cloudpack/config-types": "^0.1.1",
17
+ "@ms-cloudpack/bundler-types": "^0.23.2",
18
+ "@ms-cloudpack/package-utilities": "^5.6.2",
19
+ "@ms-cloudpack/config": "^0.17.4",
20
+ "@ms-cloudpack/config-types": "^0.1.3",
21
21
  "fast-glob": "^3.2.12",
22
22
  "glob-hasher": "^1.2.1",
23
- "object-hash": "^3.0.0"
23
+ "object-hash": "^3.0.0",
24
+ "workspace-tools": "^0.36.3"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@ms-cloudpack/eslint-plugin-internal": "*",