@ms-cloudpack/package-hashes 0.0.3 → 0.1.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.
@@ -9,17 +9,14 @@ export declare class PackageHashes {
9
9
  * Gets the hash for a given package path. This is useful for caching, to determine if the package has changed.
10
10
  * If the package definition has not been calculated, it will be calculated and cached.
11
11
  * @param packagePath - The package path to get the hash for.
12
+ * @param isSourceHashingEnabled - Whether or not to hash the source files.
13
+ * @param shouldRecalculate - Whether or not to force a re-calculation of the hash.
12
14
  * @returns The hash for the package.
13
15
  */
14
16
  get(params: {
15
17
  packagePath: string;
16
18
  isSourceHashingEnabled: boolean;
19
+ shouldRecalculate?: boolean;
17
20
  }): Promise<string>;
18
- /**
19
- * Removes the hash for a given package path from the local hash cache.
20
- * This is useful when a package has changed, and you want to force a re-calculation of the hash.
21
- * @param packagePath - The package path to remove the hash for.
22
- */
23
- remove(packagePath: string): void;
24
21
  }
25
22
  //# sourceMappingURL=PackageHashes.d.ts.map
@@ -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,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;;;;;OAKG;IACG,GAAG,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,sBAAsB,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAe5F;;;;OAIG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM;CAI3B"}
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,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"}
@@ -10,26 +10,19 @@ export class PackageHashes {
10
10
  * Gets the hash for a given package path. This is useful for caching, to determine if the package has changed.
11
11
  * If the package definition has not been calculated, it will be calculated and cached.
12
12
  * @param packagePath - The package path to get the hash for.
13
+ * @param isSourceHashingEnabled - Whether or not to hash the source files.
14
+ * @param shouldRecalculate - Whether or not to force a re-calculation of the hash.
13
15
  * @returns The hash for the package.
14
16
  */
15
17
  async get(params) {
16
- const { packagePath, isSourceHashingEnabled } = params;
18
+ const { packagePath, isSourceHashingEnabled, shouldRecalculate } = params;
17
19
  const map = isSourceHashingEnabled ? this._hashesWithSource : this._hashesWithNoSource;
18
- if (map.has(packagePath)) {
20
+ if (!shouldRecalculate && map.has(packagePath)) {
19
21
  return map.get(packagePath);
20
22
  }
21
23
  const hash = await this._hash(params);
22
24
  map.set(packagePath, hash);
23
25
  return hash;
24
26
  }
25
- /**
26
- * Removes the hash for a given package path from the local hash cache.
27
- * This is useful when a package has changed, and you want to force a re-calculation of the hash.
28
- * @param packagePath - The package path to remove the hash for.
29
- */
30
- remove(packagePath) {
31
- this._hashesWithSource.delete(packagePath);
32
- this._hashesWithNoSource.delete(packagePath);
33
- }
34
27
  }
35
28
  //# sourceMappingURL=PackageHashes.js.map
@@ -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,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;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,MAAgE;QACxE,MAAM,EAAE,WAAW,EAAE,sBAAsB,EAAE,GAAG,MAAM,CAAC;QACvD,MAAM,GAAG,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC;QAEvF,IAAI,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACxB,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;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAmB;QACxB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3C,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { hashPackage } from './hashPackage.js';\nimport type { HashFunction } from './types/HashFunctions.js';\nimport type { PackageHashesOptions } from './types/PackageHashOptions.js';\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 * @returns The hash for the package.\n */\n async get(params: { packagePath: string; isSourceHashingEnabled: boolean }): Promise<string> {\n const { packagePath, isSourceHashingEnabled } = params;\n const map = isSourceHashingEnabled ? this._hashesWithSource : this._hashesWithNoSource;\n\n if (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 /**\n * Removes the hash for a given package path from the local hash cache.\n * This is useful when a package has changed, and you want to force a re-calculation of the hash.\n * @param packagePath - The package path to remove the hash for.\n */\n remove(packagePath: string) {\n this._hashesWithSource.delete(packagePath);\n this._hashesWithNoSource.delete(packagePath);\n }\n}\n"]}
1
+ {"version":3,"file":"PackageHashes.js","sourceRoot":"","sources":["../src/PackageHashes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C,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\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(packagePath, hash);\n\n return hash;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { PackageJson } from '@ms-cloudpack/bundler-types';
2
2
  import { type ResolveMap } from '@ms-cloudpack/package-utilities';
3
- import { type CloudpackConfig } from '@ms-cloudpack/config';
3
+ import type { getPackageSettings } from '@ms-cloudpack/config';
4
4
  export declare function getInlinedDependenciesPaths(params: {
5
5
  options: {
6
6
  packageName: string;
@@ -9,7 +9,7 @@ export declare function getInlinedDependenciesPaths(params: {
9
9
  };
10
10
  context: {
11
11
  resolveMap: ResolveMap;
12
- config: CloudpackConfig;
12
+ packageSettings: ReturnType<typeof getPackageSettings>;
13
13
  };
14
14
  }): string[];
15
15
  //# sourceMappingURL=getInlinedDependenciesPaths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInlinedDependenciesPaths.d.ts","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiBhF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;KACzB,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,UAAU,CAAC;QACvB,MAAM,EAAE,eAAe,CAAC;KACzB,CAAC;CACH,YAqBA"}
1
+ {"version":3,"file":"getInlinedDependenciesPaths.d.ts","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,WAAW,CAAC;KACzB,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,UAAU,CAAC;QACvB,eAAe,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;KACxD,CAAC;CACH,YA0BA"}
@@ -1,20 +1,12 @@
1
1
  import { findResolveMapEntry } from '@ms-cloudpack/package-utilities';
2
- import { getPackageSettings } from '@ms-cloudpack/config';
3
- function getInlinedDependencies(params) {
4
- const { options, context } = params;
5
- const { packageName, version } = options;
6
- const { config } = context;
7
- const { generatedPackageSettings, userPackageSettings } = getPackageSettings({ name: packageName, version, config });
8
- return [
9
- ...(userPackageSettings?.inlinedDependencies || []),
10
- ...(generatedPackageSettings?.inlinedDependencies || []),
11
- ];
12
- }
13
2
  export function getInlinedDependenciesPaths(params) {
14
3
  const { options, context } = params;
15
4
  const { definition } = options;
16
- const { resolveMap } = context;
17
- const inlinedDependencies = getInlinedDependencies({ options, context });
5
+ const { resolveMap, packageSettings } = context;
6
+ const inlinedDependencies = [
7
+ ...(packageSettings.userPackageSettings?.inlinedDependencies || []),
8
+ ...(packageSettings.generatedPackageSettings?.inlinedDependencies || []),
9
+ ];
18
10
  const result = [];
19
11
  const inlinedDependencyEntries = inlinedDependencies.map((dependency) => findResolveMapEntry({
20
12
  packageName: dependency,
@@ -1 +1 @@
1
- {"version":3,"file":"getInlinedDependenciesPaths.js","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAwB,MAAM,sBAAsB,CAAC;AAEhF,SAAS,sBAAsB,CAAC,MAG/B;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IACzC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACrH,OAAO;QACL,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,IAAI,EAAE,CAAC;QACnD,GAAG,CAAC,wBAAwB,EAAE,mBAAmB,IAAI,EAAE,CAAC;KACzD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAU3C;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC/B,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACzE,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;QAC7D,IAAI,sBAAsB,EAAE;YAC1B,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;SAC1C;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/bundler-types';\nimport { findResolveMapEntry, type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport { getPackageSettings, type CloudpackConfig } from '@ms-cloudpack/config';\n\nfunction getInlinedDependencies(params: {\n options: { packageName: string; version: string };\n context: { config: CloudpackConfig };\n}) {\n const { options, context } = params;\n const { packageName, version } = options;\n const { config } = context;\n\n const { generatedPackageSettings, userPackageSettings } = getPackageSettings({ name: packageName, version, config });\n return [\n ...(userPackageSettings?.inlinedDependencies || []),\n ...(generatedPackageSettings?.inlinedDependencies || []),\n ];\n}\n\nexport function getInlinedDependenciesPaths(params: {\n options: {\n packageName: string;\n version: string;\n definition: PackageJson;\n };\n context: {\n resolveMap: ResolveMap;\n config: CloudpackConfig;\n };\n}) {\n const { options, context } = params;\n const { definition } = options;\n const { resolveMap } = context;\n const inlinedDependencies = getInlinedDependencies({ options, context });\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
+ {"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,MAU3C;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;QAC7D,IAAI,sBAAsB,EAAE;YAC1B,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;SAC1C;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/bundler-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 version: 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,4 +1,5 @@
1
1
  import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
2
+ import { type CloudpackConfig } from '@ms-cloudpack/config';
2
3
  /**
3
4
  * @returns the entries that are used to calculate the hash of a package
4
5
  */
@@ -8,12 +9,17 @@ export declare function getPackageHashEntries(params: {
8
9
  isSourceHashingEnabled: boolean;
9
10
  };
10
11
  context: {
12
+ config: CloudpackConfig;
11
13
  packages: PackageDefinitionsCache;
12
14
  };
13
15
  }): Promise<{
14
16
  name: string;
15
17
  version: string;
16
18
  filesHash: Record<string, string> | null | undefined;
19
+ packageSettings: {
20
+ userPackageSettings: import("@ms-cloudpack/config").PackageSettings | undefined;
21
+ generatedPackageSettings: import("@ms-cloudpack/config").PackageSettings | undefined;
22
+ };
17
23
  description?: string | undefined;
18
24
  files?: string[] | undefined;
19
25
  directories?: {
@@ -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;;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,QAAQ,EAAE,uBAAuB,CAAC;KACnC,CAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BA"}
1
+ {"version":3,"file":"getPackageHashEntries.d.ts","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAG3E,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEhF;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BA"}
@@ -1,12 +1,13 @@
1
1
  import { isExternalPackage } from '@ms-cloudpack/package-utilities';
2
2
  import { getSourceHash } from './getSourceHash.js';
3
+ import { getPackageSettings } from '@ms-cloudpack/config';
3
4
  /**
4
5
  * @returns the entries that are used to calculate the hash of a package
5
6
  */
6
7
  export async function getPackageHashEntries(params) {
7
8
  const { options, context } = params;
8
9
  const { packagePath, isSourceHashingEnabled } = options;
9
- const { packages } = context;
10
+ const { packages, config } = context;
10
11
  const definition = await packages.get(packagePath);
11
12
  if (!definition) {
12
13
  throw new Error(`Package definition (package.json) missing or invalid at "${packagePath}"`);
@@ -18,11 +19,13 @@ export async function getPackageHashEntries(params) {
18
19
  const isExternal = isExternalPackage(packagePath);
19
20
  const filesHash = !isExternal && isSourceHashingEnabled ? await getSourceHash({ packagePath }) : undefined;
20
21
  const version = (isExternal ? definition.version : packagePath) || packagePath;
22
+ const packageSettings = getPackageSettings({ name, version, config });
21
23
  return {
22
24
  ...definition,
23
25
  name,
24
26
  version,
25
27
  filesHash,
28
+ packageSettings,
26
29
  };
27
30
  }
28
31
  //# sourceMappingURL=getPackageHashEntries.js.map
@@ -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;AAEnD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAQ3C;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,GAAG,OAAO,CAAC;IAE7B,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,GAAG,UAAU,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,WAAW,GAAG,CAAC,CAAC;KACvF;IAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAElD,MAAM,SAAS,GAAG,CAAC,UAAU,IAAI,sBAAsB,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3G,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC;IAE/E,OAAO;QACL,GAAG,UAAU;QACb,IAAI;QACJ,OAAO;QACP,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { getSourceHash } from './getSourceHash.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 packages: PackageDefinitionsCache;\n };\n}) {\n const { options, context } = params;\n const { packagePath, isSourceHashingEnabled } = options;\n const { packages } = 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 } = definition;\n if (!name) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n\n const isExternal = isExternalPackage(packagePath);\n\n const filesHash = !isExternal && isSourceHashingEnabled ? await getSourceHash({ packagePath }) : undefined;\n\n const version = (isExternal ? definition.version : packagePath) || packagePath;\n\n return {\n ...definition,\n name,\n version,\n filesHash,\n };\n}\n"]}
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,EAAwB,MAAM,sBAAsB,CAAC;AAEhF;;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,GAAG,UAAU,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,sDAAsD,WAAW,GAAG,CAAC,CAAC;KACvF;IAED,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAElD,MAAM,SAAS,GAAG,CAAC,UAAU,IAAI,sBAAsB,CAAC,CAAC,CAAC,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3G,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC;IAE/E,MAAM,eAAe,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtE,OAAO;QACL,GAAG,UAAU;QACb,IAAI;QACJ,OAAO;QACP,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, type CloudpackConfig } from '@ms-cloudpack/config';\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 } = definition;\n if (!name) {\n throw new Error(`Package definition (package.json) missing name at \"${packagePath}\"`);\n }\n\n const isExternal = isExternalPackage(packagePath);\n\n const filesHash = !isExternal && isSourceHashingEnabled ? await getSourceHash({ packagePath }) : undefined;\n\n const version = (isExternal ? definition.version : packagePath) || packagePath;\n\n const packageSettings = getPackageSettings({ name, version, config });\n\n return {\n ...definition,\n name,\n version,\n filesHash,\n packageSettings,\n };\n}\n"]}
@@ -8,7 +8,7 @@ export declare function hashPackage(params: {
8
8
  };
9
9
  context: {
10
10
  packages: PackageDefinitionsCache;
11
- config?: CloudpackConfig;
11
+ config: CloudpackConfig;
12
12
  resolveMap: ResolveMap;
13
13
  };
14
14
  }): Promise<string>;
@@ -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,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAO5D,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,CAAC,EAAE,eAAe,CAAC;QACzB,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;CACH,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ClB"}
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,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAO5D,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,CA0ClB"}
@@ -19,7 +19,7 @@ export async function hashPackage(params) {
19
19
  }
20
20
  const hashEntries = await getPackageHashEntries({
21
21
  options: { isSourceHashingEnabled, packagePath: packageToHash },
22
- context: { packages },
22
+ context: { packages, config },
23
23
  });
24
24
  hashEntriesArray.push(hashEntries);
25
25
  if (config) {
@@ -29,7 +29,7 @@ export async function hashPackage(params) {
29
29
  version: hashEntries.version,
30
30
  definition: hashEntries,
31
31
  },
32
- context: { config, resolveMap },
32
+ context: { packageSettings: hashEntries.packageSettings, resolveMap },
33
33
  });
34
34
  packagesToHash.push(...inlinedDependenciesPaths);
35
35
  }
@@ -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;AACnE,OAAO,EAAwB,MAAM,sBAAsB,CAAC;AAC5D,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;SACtB,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,OAAO,EAAE,WAAW,CAAC,OAAO;oBAC5B,UAAU,EAAE,WAAW;iBACxB;gBACD,OAAO,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;aAChC,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';\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 },\n });\n\n hashEntriesArray.push(hashEntries);\n\n if (config) {\n const inlinedDependenciesPaths = getInlinedDependenciesPaths({\n options: {\n packageName: hashEntries.name,\n version: hashEntries.version,\n definition: hashEntries,\n },\n context: { config, 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;AACnE,OAAO,EAAwB,MAAM,sBAAsB,CAAC;AAC5D,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,OAAO,EAAE,WAAW,CAAC,OAAO;oBAC5B,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';\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 version: hashEntries.version,\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/package-hashes",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Utilities for hashing packages.",
5
5
  "license": "MIT",
6
6
  "type": "module",