@ms-cloudpack/package-hashes 0.7.35 → 0.7.36
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,3 +1,4 @@
|
|
|
1
|
+
import type { PackageJson } from '@ms-cloudpack/common-types';
|
|
1
2
|
export interface PackagePatchesSettings {
|
|
2
3
|
/** Working directory, used to determine the project root where patches are stored. */
|
|
3
4
|
cwd: string;
|
|
@@ -12,17 +13,20 @@ interface PackagePatch {
|
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* PackagePatchesCache manages a cache of information about patch files, which are usually stored in the
|
|
15
|
-
* `patches` folder at the root of the repo
|
|
16
|
-
* path and contents for a given package name and version.
|
|
16
|
+
* `patches` folder at the root of the repo (also handles yarn v2+ patches).
|
|
17
17
|
*/
|
|
18
18
|
export declare class PackagePatchesCache {
|
|
19
19
|
private readonly settings;
|
|
20
20
|
/**
|
|
21
|
-
* Mapping from
|
|
22
|
-
*
|
|
23
|
-
* (
|
|
21
|
+
* Mapping from package key (see `getKey`) to patch file path and contents.
|
|
22
|
+
*
|
|
23
|
+
* The paths from `globPattern` (or `defaultGlobPattern`) are saved in an initial pass, but the
|
|
24
|
+
* contents are only read on first request (in case of very large patches for packages that
|
|
25
|
+
* cloudpack doesn't process). Yarn v2+ patches are also lazy loaded.
|
|
24
26
|
*/
|
|
25
27
|
private _patches;
|
|
28
|
+
private _loaded;
|
|
29
|
+
private _rootPath;
|
|
26
30
|
constructor(settings: PackagePatchesSettings);
|
|
27
31
|
private getKey;
|
|
28
32
|
/**
|
|
@@ -32,11 +36,9 @@ export declare class PackagePatchesCache {
|
|
|
32
36
|
private readPatchFile;
|
|
33
37
|
/**
|
|
34
38
|
* Gets info about the patch file for the specified package.
|
|
35
|
-
* @param packageName - The name of the package to check.
|
|
36
|
-
* @param version - The version of the package to check.
|
|
37
39
|
* @returns Patch file path and contents if the package has been patched, undefined otherwise.
|
|
38
40
|
*/
|
|
39
|
-
getPackagePatch(
|
|
41
|
+
getPackagePatch(definition: PackageJson): Promise<PackagePatch | undefined>;
|
|
40
42
|
}
|
|
41
43
|
export {};
|
|
42
44
|
//# sourceMappingURL=PackagePatchesCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackagePatchesCache.d.ts","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PackagePatchesCache.d.ts","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAK9D,MAAM,WAAW,sBAAsB;IACrC,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAC;IAEZ,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,YAAY,CAAC,CAAC;CACvD;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAYlB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAXrC;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAA8C;IAC9D,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAqB;gBAET,QAAQ,EAAE,sBAAsB;IAI7D,OAAO,CAAC,MAAM;IAId;;OAEG;YACW,mBAAmB;YA+BnB,aAAa;IAS3B;;;OAGG;IACU,eAAe,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;CA0BzF"}
|
|
@@ -3,21 +3,27 @@ import fsPromises from 'fs/promises';
|
|
|
3
3
|
import glob from 'fast-glob';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { parsePatchFilePath } from './parsePatchFilePath.js';
|
|
6
|
+
/** Default `patch-package` patches path. (yarn v2+ patches are handled separately.) */
|
|
7
|
+
const defaultGlobPattern = 'patches/*.patch';
|
|
6
8
|
/**
|
|
7
9
|
* PackagePatchesCache manages a cache of information about patch files, which are usually stored in the
|
|
8
|
-
* `patches` folder at the root of the repo
|
|
9
|
-
* path and contents for a given package name and version.
|
|
10
|
+
* `patches` folder at the root of the repo (also handles yarn v2+ patches).
|
|
10
11
|
*/
|
|
11
12
|
export class PackagePatchesCache {
|
|
12
13
|
settings;
|
|
13
14
|
/**
|
|
14
|
-
* Mapping from
|
|
15
|
-
*
|
|
16
|
-
* (
|
|
15
|
+
* Mapping from package key (see `getKey`) to patch file path and contents.
|
|
16
|
+
*
|
|
17
|
+
* The paths from `globPattern` (or `defaultGlobPattern`) are saved in an initial pass, but the
|
|
18
|
+
* contents are only read on first request (in case of very large patches for packages that
|
|
19
|
+
* cloudpack doesn't process). Yarn v2+ patches are also lazy loaded.
|
|
17
20
|
*/
|
|
18
21
|
_patches;
|
|
22
|
+
_loaded = false;
|
|
23
|
+
_rootPath;
|
|
19
24
|
constructor(settings) {
|
|
20
25
|
this.settings = settings;
|
|
26
|
+
this._patches = settings.patches || {};
|
|
21
27
|
}
|
|
22
28
|
getKey(packageName, version) {
|
|
23
29
|
return `${packageName}@${version}`;
|
|
@@ -26,20 +32,15 @@ export class PackagePatchesCache {
|
|
|
26
32
|
* Loads the list of patched packages from the `patches` folder.
|
|
27
33
|
*/
|
|
28
34
|
async loadPatchedPackages() {
|
|
29
|
-
if (this.
|
|
30
|
-
this._patches = this.settings.patches;
|
|
35
|
+
if (this._loaded) {
|
|
31
36
|
return;
|
|
32
37
|
}
|
|
33
|
-
this.
|
|
38
|
+
this._loaded = true;
|
|
34
39
|
// get the repo root
|
|
35
|
-
|
|
36
|
-
if (!rootPath) {
|
|
37
|
-
console.info('Could not find the root of the repo. Skipping loading patched packages.');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
+
this._rootPath = findProjectRoot(this.settings.cwd) || this.settings.cwd;
|
|
40
41
|
// get the files with .patch extension
|
|
41
|
-
const patchFiles = await glob(this.settings.globPattern ||
|
|
42
|
-
cwd:
|
|
42
|
+
const patchFiles = await glob(this.settings.globPattern || defaultGlobPattern, {
|
|
43
|
+
cwd: this._rootPath,
|
|
43
44
|
absolute: true,
|
|
44
45
|
});
|
|
45
46
|
for (const absoluteFilePath of patchFiles) {
|
|
@@ -65,15 +66,22 @@ export class PackagePatchesCache {
|
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Gets info about the patch file for the specified package.
|
|
68
|
-
* @param packageName - The name of the package to check.
|
|
69
|
-
* @param version - The version of the package to check.
|
|
70
69
|
* @returns Patch file path and contents if the package has been patched, undefined otherwise.
|
|
71
70
|
*/
|
|
72
|
-
async getPackagePatch(
|
|
73
|
-
if (!this.
|
|
71
|
+
async getPackagePatch(definition) {
|
|
72
|
+
if (!this._loaded) {
|
|
74
73
|
await this.loadPatchedPackages();
|
|
75
74
|
}
|
|
76
|
-
const
|
|
75
|
+
const key = this.getKey(definition.name, definition.version);
|
|
76
|
+
let patchInfo = this._patches[key];
|
|
77
|
+
if (!patchInfo && definition.cloudpack?.patchFilePath && this._rootPath) {
|
|
78
|
+
// Yarn v2+ patch files don't use a parseable name, so we handle them separately.
|
|
79
|
+
// The file paths are like .yarn/patches/@foo-bar-baz-npm-4.3.0-e85334d38f.patch
|
|
80
|
+
// without a way to distinguish where the scope ends.
|
|
81
|
+
console.debug(`Found yarn patch file for package: ${key}`);
|
|
82
|
+
patchInfo = { path: path.join(this._rootPath, definition.cloudpack.patchFilePath) };
|
|
83
|
+
this._patches[key] = patchInfo;
|
|
84
|
+
}
|
|
77
85
|
if (patchInfo) {
|
|
78
86
|
// The contents are lazy loaded
|
|
79
87
|
patchInfo.contents ??= await this.readPatchFile(patchInfo.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackagePatchesCache.js","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"PackagePatchesCache.js","sourceRoot":"","sources":["../src/PackagePatchesCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,uFAAuF;AACvF,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAkB7C;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAYD;IAX7B;;;;;;OAMG;IACK,QAAQ,CAA8C;IACtD,OAAO,GAAG,KAAK,CAAC;IAChB,SAAS,CAAqB;IAEtC,YAA6B,QAAgC;QAAhC,aAAQ,GAAR,QAAQ,CAAwB;QAC3D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,WAAmB,EAAE,OAAe;QACjD,OAAO,GAAG,WAAW,IAAI,OAAO,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,mBAAmB;QAC/B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QAEpB,oBAAoB;QACpB,IAAI,CAAC,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAA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AAmB,EAAE,CAAC;QACnC,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;QAE7D,IAAI,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEnC,IAAI,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,EAAE,aAAa,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACxE,iFAAiF;YACjF,gFAAgF;YAChF,qDAAqD;YACrD,OAAO,CAAC,KAAK,CAAC,sCAAsC,GAAG,EAAE,CAAC,CAAC;YAC3D,SAAS,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;YACpF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;QACjC,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACd,+BAA+B;YAC/B,SAAS,CAAC,QAAQ,KAAK,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAChE,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { findProjectRoot } from '@ms-cloudpack/path-utilities';\nimport fsPromises from 'fs/promises';\nimport glob from 'fast-glob';\nimport path from 'path';\nimport { parsePatchFilePath } from './parsePatchFilePath.js';\nimport type { PackageJson } from '@ms-cloudpack/common-types';\n\n/** Default `patch-package` patches path. (yarn v2+ patches are handled separately.) */\nconst defaultGlobPattern = 'patches/*.patch';\n\nexport interface PackagePatchesSettings {\n /** Working directory, used to determine the project root where patches are stored. */\n cwd: string;\n\n /** Custom glob pattern for patch files (from `AppConfig.patchFilesGlobPattern`). */\n globPattern?: string;\n\n /** Patches to use instead of reading from disk (for testing). */\n patches?: Record<`${string}@${string}`, PackagePatch>;\n}\n\ninterface PackagePatch {\n path: string;\n contents?: string;\n}\n\n/**\n * PackagePatchesCache manages a cache of information about patch files, which are usually stored in the\n * `patches` folder at the root of the repo (also handles yarn v2+ patches).\n */\nexport class PackagePatchesCache {\n /**\n * Mapping from package key (see `getKey`) to patch file path and contents.\n *\n * The paths from `globPattern` (or `defaultGlobPattern`) are saved in an initial pass, but the\n * contents are only read on first request (in case of very large patches for packages that\n * cloudpack doesn't process). Yarn v2+ patches are also lazy loaded.\n */\n private _patches: Record<`${string}@${string}`, PackagePatch>;\n private _loaded = false;\n private _rootPath: string | undefined;\n\n constructor(private readonly settings: PackagePatchesSettings) {\n this._patches = settings.patches || {};\n }\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(): Promise<void> {\n if (this._loaded) {\n return;\n }\n\n this._loaded = true;\n\n // get the repo root\n this._rootPath = findProjectRoot(this.settings.cwd) || this.settings.cwd;\n\n // get the files with .patch extension\n const patchFiles = await glob(this.settings.globPattern || defaultGlobPattern, {\n cwd: this._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)] = { path: normalizedPath };\n } catch (e) {\n console.warn(`Invalid patch file \"${absoluteFilePath}\": ${e}`);\n }\n }\n }\n\n private async readPatchFile(patchFilePath: string): Promise<string> {\n try {\n return await fsPromises.readFile(patchFilePath, 'utf-8');\n } catch (e) {\n console.warn(`Error reading patch file \"${patchFilePath}\": ${e}`);\n return '';\n }\n }\n\n /**\n * Gets info about the patch file for the specified package.\n * @returns Patch file path and contents if the package has been patched, undefined otherwise.\n */\n public async getPackagePatch(definition: PackageJson): Promise<PackagePatch | undefined> {\n if (!this._loaded) {\n await this.loadPatchedPackages();\n }\n\n const key = this.getKey(definition.name, definition.version);\n\n let patchInfo = this._patches[key];\n\n if (!patchInfo && definition.cloudpack?.patchFilePath && this._rootPath) {\n // Yarn v2+ patch files don't use a parseable name, so we handle them separately.\n // The file paths are like .yarn/patches/@foo-bar-baz-npm-4.3.0-e85334d38f.patch\n // without a way to distinguish where the scope ends.\n console.debug(`Found yarn patch file for package: ${key}`);\n patchInfo = { path: path.join(this._rootPath, definition.cloudpack.patchFilePath) };\n this._patches[key] = patchInfo;\n }\n\n if (patchInfo) {\n // The contents are lazy loaded\n patchInfo.contents ??= await this.readPatchFile(patchInfo.path);\n return patchInfo;\n }\n\n return undefined;\n }\n}\n"]}
|
|
@@ -16,7 +16,7 @@ export async function getPackageHashEntries(params) {
|
|
|
16
16
|
const filesHash = !isExternal && isSourceHashingEnabled
|
|
17
17
|
? await getSourceHash({ packagePath, inputPaths: packageSettings.inputPaths })
|
|
18
18
|
: undefined;
|
|
19
|
-
const patchFileContent = isExternal ? (await patches.getPackagePatch(
|
|
19
|
+
const patchFileContent = isExternal ? (await patches.getPackagePatch(definition))?.contents : undefined;
|
|
20
20
|
// Only include a subset of package.json properties to reduce the amount hashed.
|
|
21
21
|
const result = {
|
|
22
22
|
// This will be calculated by createPackageSettingsTransform and incorporates the original
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageHashEntries.js","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAkB,MAAM,oBAAoB,CAAC;AA0BnE;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAO3C;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC;IAC3E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,MAAM,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;IACjE,CAAC;IAED,sEAAsE;IACtE,IAAI,iBAAiB,KAAK,SAAS,EAAE,CAAC;QACpC,MAAM,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type {\n PackageDefinitionsCache,\n PackageJsonCloudpackMeta,\n PackageJsonDependencies,\n PackageJsonExports,\n TargetEnvironment,\n} from '@ms-cloudpack/common-types';\nimport { isExternalPackage } from '@ms-cloudpack/path-utilities';\nimport type { HashFunctionOptions } from './types/HashFunction.js';\nimport { getSourceHash, type FilesHash } from './getSourceHash.js';\nimport type { PackagePatchesCache } from './PackagePatchesCache.js';\nimport type { BundlerCapabilitiesCache } from './BundlerCapabilitiesCache.js';\n\n/**\n * Values used to calculate the hash of a package.\n */\nexport interface PackageHashEntries {\n name: string;\n /** This will be the actual version if the package is external, or the path if it's internal. */\n version: string;\n exports: PackageJsonExports | undefined;\n dependencies: PackageJsonDependencies | undefined;\n peerDependencies: PackageJsonDependencies | undefined;\n /** Hash of files in the package. */\n filesHash: FilesHash | undefined;\n /** Content of any `.patch` file for the package. */\n patchFileContent: string | undefined;\n /** Subset of calculated package settings and other info saved under `PackageJson.cloudpack`. */\n packageSettings: Partial<PackageJsonCloudpackMeta>;\n /** Content of any bundler capabilities files for the package. */\n bundlerCapabilitiesContent?: Record<string, string>;\n /** Target environment, if not `'browser'` */\n targetEnvironment?: TargetEnvironment;\n}\n\n/**\n * Get an object that's used to calculate the hash of the package.\n */\nexport async function getPackageHashEntries(params: {\n options: HashFunctionOptions;\n context: {\n packages: PackageDefinitionsCache;\n patches: PackagePatchesCache;\n bundlerCapabilitiesCache: BundlerCapabilitiesCache;\n };\n}): Promise<PackageHashEntries> {\n const { options, context } = params;\n const { packagePath, targetEnvironment, isSourceHashingEnabled } = options;\n const { packages, patches, bundlerCapabilitiesCache } = context;\n\n const definition = await packages.get(packagePath);\n const originalDefinition = await packages.get(packagePath, { disableTransforms: true });\n\n const { name, version } = definition;\n\n // This has the cached calculated package settings, with included and excluded deps removed.\n const packageSettings = { ...definition.cloudpack };\n\n const isExternal = isExternalPackage(packagePath);\n\n const filesHash =\n !isExternal && isSourceHashingEnabled\n ? await getSourceHash({ packagePath, inputPaths: packageSettings.inputPaths })\n : undefined;\n\n const patchFileContent = isExternal ? (await patches.getPackagePatch(definition))?.contents : undefined;\n\n // Only include a subset of package.json properties to reduce the amount hashed.\n const result: PackageHashEntries = {\n // This will be calculated by createPackageSettingsTransform and incorporates the original\n // exports as well as main and module.\n exports: definition.exports,\n // Use the original dependencies to ensure that the hash is consistent,\n // and unaffected by include and exclude changes.\n dependencies: originalDefinition.dependencies,\n peerDependencies: originalDefinition.peerDependencies,\n name,\n version: isExternal ? version : packagePath,\n filesHash,\n patchFileContent,\n packageSettings,\n };\n\n const bundlerCapabilitiesContent = await bundlerCapabilitiesCache.get(packageSettings.bundlerCapabilities);\n if (Object.keys(bundlerCapabilitiesContent || {}).length > 0) {\n result.bundlerCapabilitiesContent = bundlerCapabilitiesContent;\n }\n\n // Conditionally setting this prevents invalidating all cached content\n if (targetEnvironment !== 'browser') {\n result.targetEnvironment = targetEnvironment;\n }\n\n return result;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-hashes",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.36",
|
|
4
4
|
"description": "Utilities for hashing packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.24.
|
|
18
|
-
"@ms-cloudpack/config": "^0.33.
|
|
19
|
-
"@ms-cloudpack/package-utilities": "^12.0.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.24.12",
|
|
18
|
+
"@ms-cloudpack/config": "^0.33.24",
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^12.0.3",
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.2.6",
|
|
21
|
-
"@ms-cloudpack/path-utilities": "^3.0.
|
|
21
|
+
"@ms-cloudpack/path-utilities": "^3.0.9",
|
|
22
22
|
"fast-glob": "^3.2.12",
|
|
23
23
|
"glob-hasher": "^1.4.2",
|
|
24
24
|
"object-hash": "^3.0.0"
|