@ms-cloudpack/package-hashes 0.6.18 → 0.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/getInlinedDependenciesPaths.d.ts +1 -2
- package/lib/getInlinedDependenciesPaths.d.ts.map +1 -1
- package/lib/getInlinedDependenciesPaths.js +2 -6
- package/lib/getInlinedDependenciesPaths.js.map +1 -1
- package/lib/getPackageHashEntries.d.ts +17 -55
- package/lib/getPackageHashEntries.d.ts.map +1 -1
- package/lib/getPackageHashEntries.js +13 -21
- package/lib/getPackageHashEntries.js.map +1 -1
- package/lib/getSourceHash.d.ts +2 -4
- package/lib/getSourceHash.d.ts.map +1 -1
- package/lib/getSourceHash.js +1 -2
- package/lib/getSourceHash.js.map +1 -1
- package/lib/hashPackage.d.ts +1 -2
- package/lib/hashPackage.d.ts.map +1 -1
- package/lib/hashPackage.js +5 -4
- package/lib/hashPackage.js.map +1 -1
- package/lib/types/PackageHashOptions.d.ts +1 -1
- package/lib/types/PackageHashOptions.d.ts.map +1 -1
- package/lib/types/PackageHashOptions.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { PackageJson } from '@ms-cloudpack/common-types';
|
|
2
2
|
import { type ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
3
|
-
import type { getPackageSettings } from '@ms-cloudpack/config';
|
|
4
3
|
export declare function getInlinedDependenciesPaths(params: {
|
|
5
4
|
options: {
|
|
6
5
|
packageName: string;
|
|
7
6
|
definition: PackageJson;
|
|
7
|
+
inlinedDependencies: string[];
|
|
8
8
|
};
|
|
9
9
|
context: {
|
|
10
10
|
resolveMap: ResolveMap;
|
|
11
|
-
packageSettings: ReturnType<typeof getPackageSettings>;
|
|
12
11
|
};
|
|
13
12
|
}): string[];
|
|
14
13
|
//# 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,4BAA4B,CAAC;AAC9D,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"getInlinedDependenciesPaths.d.ts","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAEvF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,WAAW,CAAC;QACxB,mBAAmB,EAAE,MAAM,EAAE,CAAC;KAC/B,CAAC;IACF,OAAO,EAAE;QACP,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;CACH,YAqBA"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { findResolveMapEntry } from '@ms-cloudpack/package-utilities';
|
|
2
2
|
export function getInlinedDependenciesPaths(params) {
|
|
3
3
|
const { options, context } = params;
|
|
4
|
-
const { definition } = options;
|
|
5
|
-
const { resolveMap
|
|
6
|
-
const inlinedDependencies = [
|
|
7
|
-
...(packageSettings.userPackageSettings?.inlinedDependencies || []),
|
|
8
|
-
...(packageSettings.generatedPackageSettings?.inlinedDependencies || []),
|
|
9
|
-
];
|
|
4
|
+
const { definition, inlinedDependencies } = options;
|
|
5
|
+
const { resolveMap } = context;
|
|
10
6
|
const result = [];
|
|
11
7
|
const inlinedDependencyEntries = inlinedDependencies.map((dependency) => findResolveMapEntry({
|
|
12
8
|
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;
|
|
1
|
+
{"version":3,"file":"getInlinedDependenciesPaths.js","sourceRoot":"","sources":["../src/getInlinedDependenciesPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAmB,MAAM,iCAAiC,CAAC;AAEvF,MAAM,UAAU,2BAA2B,CAAC,MAS3C;IACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IACpC,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,wBAAwB,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACtE,mBAAmB,CAAC;QAClB,WAAW,EAAE,UAAU;QACvB,UAAU;QACV,UAAU;KACX,CAAC,CACH,CAAC;IAEF,KAAK,MAAM,sBAAsB,IAAI,wBAAwB,EAAE,CAAC;QAC9D,IAAI,sBAAsB,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageJson } from '@ms-cloudpack/common-types';\nimport { findResolveMapEntry, type ResolveMap } from '@ms-cloudpack/package-utilities';\n\nexport function getInlinedDependenciesPaths(params: {\n options: {\n packageName: string;\n definition: PackageJson;\n inlinedDependencies: string[];\n };\n context: {\n resolveMap: ResolveMap;\n };\n}) {\n const { options, context } = params;\n const { definition, inlinedDependencies } = options;\n const { resolveMap } = context;\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,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
2
2
|
import type { PackagePatches } from './types/PackagePatches.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Get an object that's used to calculate the hash of the package.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getPackageHashEntries(params: {
|
|
7
7
|
options: {
|
|
@@ -9,69 +9,31 @@ export declare function getPackageHashEntries(params: {
|
|
|
9
9
|
isSourceHashingEnabled: boolean;
|
|
10
10
|
};
|
|
11
11
|
context: {
|
|
12
|
-
config: CloudpackConfig;
|
|
13
12
|
packages: PackageDefinitionsCache;
|
|
14
13
|
patches: PackagePatches;
|
|
15
14
|
};
|
|
16
15
|
}): Promise<{
|
|
16
|
+
exports: import("@ms-cloudpack/common-types").PackageJsonExports | undefined;
|
|
17
17
|
dependencies: Partial<Record<string, string>> | undefined;
|
|
18
|
+
peerDependencies: Partial<Record<string, string>> | undefined;
|
|
18
19
|
name: string;
|
|
19
20
|
version: string;
|
|
20
21
|
filesHash: Record<string, string | null | undefined> | null | undefined;
|
|
21
22
|
patchFileContent: string | undefined;
|
|
22
23
|
packageSettings: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
bin?: string | Partial<Record<string, string>>;
|
|
37
|
-
esnext?: string | {
|
|
38
|
-
[moduleName: string]: string | undefined;
|
|
39
|
-
main?: string;
|
|
40
|
-
browser?: string;
|
|
41
|
-
};
|
|
42
|
-
browser?: string | Partial<Record<string, string | false>>;
|
|
43
|
-
sideEffects?: boolean | string[];
|
|
44
|
-
types?: string;
|
|
45
|
-
typings?: string;
|
|
46
|
-
typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
|
|
47
|
-
exports?: import("@ms-cloudpack/common-types").PackageJsonExports;
|
|
48
|
-
imports?: import("@ms-cloudpack/common-types").PackageJsonImports;
|
|
49
|
-
devDependencies?: import("@ms-cloudpack/common-types").PackageJsonDependencies;
|
|
50
|
-
peerDependencies?: import("@ms-cloudpack/common-types").PackageJsonDependencies;
|
|
51
|
-
peerDependenciesMeta?: Partial<Record<string, {
|
|
52
|
-
optional: true;
|
|
53
|
-
}>>;
|
|
54
|
-
optionalDependencies?: import("@ms-cloudpack/common-types").PackageJsonDependencies;
|
|
55
|
-
bundledDependencies?: import("@ms-cloudpack/common-types").PackageJsonDependencies | string[];
|
|
56
|
-
bundleDependencies?: import("@ms-cloudpack/common-types").PackageJsonDependencies | string[];
|
|
57
|
-
resolutions?: import("@ms-cloudpack/common-types").PackageJsonDependencies;
|
|
58
|
-
engines?: { [engine in import("@ms-cloudpack/common-types").LiteralOrString<"npm" | "node">]?: string; };
|
|
59
|
-
os?: Array<import("@ms-cloudpack/common-types").LiteralOrString<"aix" | "darwin" | "freebsd" | "linux" | "openbsd" | "sunos" | "win32" | "!aix" | "!darwin" | "!freebsd" | "!linux" | "!openbsd" | "!sunos" | "!win32">>;
|
|
60
|
-
cpu?: Array<import("@ms-cloudpack/common-types").LiteralOrString<"arm" | "arm64" | "ia32" | "mips" | "mipsel" | "ppc" | "ppc64" | "s390" | "s390x" | "x32" | "x64" | "!arm" | "!arm64" | "!ia32" | "!mips" | "!mipsel" | "!ppc" | "!ppc64" | "!s390" | "!s390x" | "!x32" | "!x64">>;
|
|
61
|
-
private?: boolean;
|
|
62
|
-
publishConfig?: {
|
|
63
|
-
access?: "public" | "restricted";
|
|
64
|
-
registry?: string;
|
|
65
|
-
tag?: string;
|
|
66
|
-
[additionalProperties: string]: unknown;
|
|
67
|
-
};
|
|
68
|
-
packageManager?: string;
|
|
69
|
-
workspaces?: string[] | {
|
|
70
|
-
packages?: string[];
|
|
71
|
-
nohoist?: string[];
|
|
72
|
-
};
|
|
73
|
-
cloudpack?: Omit<PackageSettings, "match"> & {
|
|
74
|
-
mode: import("@ms-cloudpack/common-types").BundleMode;
|
|
24
|
+
inputPaths?: string[];
|
|
25
|
+
link?: {
|
|
26
|
+
duplicatedDependencyBehavior?: "force-host-version" | "allow-duplication" | "force-remote-version";
|
|
27
|
+
};
|
|
28
|
+
inlinedDependencies?: string[];
|
|
29
|
+
bundler?: string;
|
|
30
|
+
bundlerType?: string;
|
|
31
|
+
bundlerOptions?: Record<string, unknown>;
|
|
32
|
+
ignoreMissingExports?: boolean | Record<string, string[]>;
|
|
33
|
+
dynamicImports?: string[];
|
|
34
|
+
ignoredBundlerWarnings?: string[];
|
|
35
|
+
bundlerCapabilities?: import("@ms-cloudpack/common-types").BundlerCapabilitiesOptions;
|
|
36
|
+
mode?: import("@ms-cloudpack/common-types").BundleMode | undefined;
|
|
75
37
|
};
|
|
76
38
|
}>;
|
|
77
39
|
//# sourceMappingURL=getPackageHashEntries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageHashEntries.d.ts","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"getPackageHashEntries.d.ts","sourceRoot":"","sources":["../src/getPackageHashEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E,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,QAAQ,EAAE,uBAAuB,CAAC;QAClC,OAAO,EAAE,cAAc,CAAC;KACzB,CAAC;CACH;;;;;;;;;;;wCAgDk3F,CAAC;;;;;;;;;;;;GADn3F"}
|
|
@@ -1,14 +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';
|
|
4
3
|
import { getPatchFileContent } from './getPatchFileContent.js';
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* Get an object that's used to calculate the hash of the package.
|
|
7
6
|
*/
|
|
8
7
|
export async function getPackageHashEntries(params) {
|
|
9
8
|
const { options, context } = params;
|
|
10
9
|
const { packagePath, isSourceHashingEnabled } = options;
|
|
11
|
-
const { packages,
|
|
10
|
+
const { packages, patches } = context;
|
|
12
11
|
const definition = await packages.get(packagePath);
|
|
13
12
|
const disabledTransformsDefinition = await packages.get(packagePath, { disableTransforms: true });
|
|
14
13
|
if (!definition) {
|
|
@@ -21,29 +20,22 @@ export async function getPackageHashEntries(params) {
|
|
|
21
20
|
if (!version) {
|
|
22
21
|
throw new Error(`Package definition (package.json) missing version at "${packagePath}"`);
|
|
23
22
|
}
|
|
23
|
+
// This has the cached calculated package settings, with included and excluded deps removed.
|
|
24
|
+
const packageSettings = { ...definition.cloudpack };
|
|
24
25
|
const isExternal = isExternalPackage(packagePath);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
userPackageSettings: config.packageSettings,
|
|
29
|
-
generatedPackageSettings: config.generated.packageSettings,
|
|
30
|
-
});
|
|
31
|
-
// Homogenize the package settings to ensure that the hash is consistent even with empty settings.
|
|
32
|
-
packageSettings.userPackageSettings ??= {};
|
|
33
|
-
packageSettings.generatedPackageSettings ??= {};
|
|
34
|
-
// We can delete these properties because they affect Cloudpack internals,
|
|
35
|
-
// but not the reusability of the bundled package.
|
|
36
|
-
delete packageSettings.userPackageSettings.includedDependencies;
|
|
37
|
-
delete packageSettings.userPackageSettings.excludedDependencies;
|
|
38
|
-
delete packageSettings.generatedPackageSettings.includedDependencies;
|
|
39
|
-
delete packageSettings.generatedPackageSettings.excludedDependencies;
|
|
40
|
-
const filesHash = !isExternal && isSourceHashingEnabled ? await getSourceHash({ packagePath, packageSettings }) : undefined;
|
|
26
|
+
const filesHash = !isExternal && isSourceHashingEnabled
|
|
27
|
+
? await getSourceHash({ packagePath, inputPaths: packageSettings.inputPaths })
|
|
28
|
+
: undefined;
|
|
41
29
|
const patchFileContent = isExternal ? await getPatchFileContent(patches, name, version) : undefined;
|
|
30
|
+
// Only include a subset of package.json properties to reduce the amount hashed.
|
|
42
31
|
return {
|
|
43
|
-
|
|
44
|
-
//
|
|
32
|
+
// This will be calculated by createPackageSettingsTransform and incorporates the original
|
|
33
|
+
// exports as well as main and module.
|
|
34
|
+
exports: definition.exports,
|
|
35
|
+
// Use the original dependencies to ensure that the hash is consistent,
|
|
45
36
|
// and unaffected by include and exclude changes.
|
|
46
37
|
dependencies: disabledTransformsDefinition?.dependencies,
|
|
38
|
+
peerDependencies: disabledTransformsDefinition?.peerDependencies,
|
|
47
39
|
name,
|
|
48
40
|
version: isExternal ? version : packagePath,
|
|
49
41
|
filesHash,
|
|
@@ -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;
|
|
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,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,MAAM,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AAC,CAAC,SAAS,CAAC;IAEpG,gFAAgF;IAChF,OAAO;QACL,0FAA0F;QAC1F,sCAAsC;QACtC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,uEAAuE;QACvE,iDAAiD;QACjD,YAAY,EAAE,4BAA4B,EAAE,YAAY;QACxD,gBAAgB,EAAE,4BAA4B,EAAE,gBAAgB;QAChE,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/common-types';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { getSourceHash } from './getSourceHash.js';\nimport type { PackagePatches } from './types/PackagePatches.js';\nimport { getPatchFileContent } from './getPatchFileContent.js';\n\n/**\n * Get an object that's used to calculate the hash of the package.\n */\nexport async function getPackageHashEntries(params: {\n options: {\n packagePath: string;\n isSourceHashingEnabled: boolean;\n };\n context: {\n packages: PackageDefinitionsCache;\n patches: PackagePatches;\n };\n}) {\n const { options, context } = params;\n const { packagePath, isSourceHashingEnabled } = options;\n const { packages, patches } = context;\n\n const definition = await packages.get(packagePath);\n const disabledTransformsDefinition = await packages.get(packagePath, { disableTransforms: true });\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 // 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 getPatchFileContent(patches, name, version) : undefined;\n\n // Only include a subset of package.json properties to reduce the amount hashed.\n return {\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: disabledTransformsDefinition?.dependencies,\n peerDependencies: disabledTransformsDefinition?.peerDependencies,\n name,\n version: isExternal ? version : packagePath,\n filesHash,\n patchFileContent,\n packageSettings,\n };\n}\n"]}
|
package/lib/getSourceHash.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PackageSettings } from '@ms-cloudpack/common-types';
|
|
2
1
|
/**
|
|
3
2
|
* Get the hash of the source files in a package
|
|
4
3
|
* If there is a src folder, hash the files in that folder, the .*json files and the inputPaths
|
|
@@ -7,8 +6,7 @@ import type { PackageSettings } from '@ms-cloudpack/common-types';
|
|
|
7
6
|
*/
|
|
8
7
|
export declare function getSourceHash(options: {
|
|
9
8
|
packagePath: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
9
|
+
/** Input paths from the package settings */
|
|
10
|
+
inputPaths: string[] | undefined;
|
|
13
11
|
}): Promise<Record<string, string | null | undefined> | null>;
|
|
14
12
|
//# sourceMappingURL=getSourceHash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSourceHash.d.ts","sourceRoot":"","sources":["../src/getSourceHash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSourceHash.d.ts","sourceRoot":"","sources":["../src/getSourceHash.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,UAAU,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAClC,6DA4BA"}
|
package/lib/getSourceHash.js
CHANGED
|
@@ -12,8 +12,7 @@ const excludeNodeModules = '!**/node_modules/**';
|
|
|
12
12
|
*/
|
|
13
13
|
export async function getSourceHash(options) {
|
|
14
14
|
const start = performance.now();
|
|
15
|
-
const { packagePath,
|
|
16
|
-
const inputPaths = packageSettings?.userPackageSettings?.inputPaths;
|
|
15
|
+
const { packagePath, inputPaths } = options;
|
|
17
16
|
// Use the inputPaths if they are defined, otherwise use the src folder if it exists
|
|
18
17
|
// Otherwise, use all files except node_modules
|
|
19
18
|
let patterns;
|
package/lib/getSourceHash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSourceHash.js","sourceRoot":"","sources":["../src/getSourceHash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSourceHash.js","sourceRoot":"","sources":["../src/getSourceHash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAInC;IACC,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAEhC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAC5C,oFAAoF;IACpF,+CAA+C;IAC/C,IAAI,QAAkB,CAAC;IACvB,IAAI,UAAU,EAAE,MAAM,EAAE,CAAC;QACvB,QAAQ,GAAG,UAAU,CAAC;IACxB,CAAC;SAAM,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QACrD,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,QAAQ,GAAG,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE;QACjC,GAAG,EAAE,WAAW;QAChB,4GAA4G;QAC5G,wFAAwF;QACxF,qFAAqF;QACrF,MAAM,EAAE,CAAC,iBAAiB,EAAE,uBAAuB,CAAC;KACrD,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;IAEnD,OAAO,CAAC,KAAK,CAAC,0BAA0B,WAAW,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;IAEzF,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { appConfigFileName, generatedConfigFileName } from '@ms-cloudpack/config';\nimport glob from 'fast-glob';\nimport { existsSync } from 'fs';\nimport { hash } from 'glob-hasher';\nimport path from 'path';\n\nconst excludeNodeModules = '!**/node_modules/**';\n\n/**\n * Get the hash of the source files in a package\n * If there is a src folder, hash the files in that folder, the .*json files and the inputPaths\n * If there are inputPaths, hash those files in addition to the .*json files\n * Otherwise, hash all files except node_modules\n */\nexport async function getSourceHash(options: {\n packagePath: string;\n /** Input paths from the package settings */\n inputPaths: string[] | undefined;\n}) {\n const start = performance.now();\n\n const { packagePath, inputPaths } = options;\n // Use the inputPaths if they are defined, otherwise use the src folder if it exists\n // Otherwise, use all files except node_modules\n let patterns: string[];\n if (inputPaths?.length) {\n patterns = inputPaths;\n } else if (existsSync(path.join(packagePath, 'src'))) {\n patterns = ['src/**', '*.json', excludeNodeModules];\n } else {\n patterns = ['**', excludeNodeModules];\n }\n\n const files = await glob(patterns, {\n cwd: packagePath,\n // We want to ignore the app config and generated config files because they are not part of the source code.\n // Ignoring the generated config is especially important because it changes during init,\n // and it would invalidate the cache for the entry package with the generated config.\n ignore: [appConfigFileName, generatedConfigFileName],\n });\n\n const globHash = hash(files, { cwd: packagePath });\n\n console.debug(`Hashed source files in ${packagePath} in ${performance.now() - start}ms`);\n\n return globHash;\n}\n"]}
|
package/lib/hashPackage.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';
|
|
2
2
|
import { type ResolveMap } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
import type { PackagePatches } from './types/PackagePatches.js';
|
|
4
4
|
export declare function hashPackage(params: {
|
|
@@ -8,7 +8,6 @@ export declare function hashPackage(params: {
|
|
|
8
8
|
};
|
|
9
9
|
context: {
|
|
10
10
|
packages: PackageDefinitionsCache;
|
|
11
|
-
config: CloudpackConfig;
|
|
12
11
|
resolveMap: ResolveMap;
|
|
13
12
|
patches: PackagePatches;
|
|
14
13
|
};
|
package/lib/hashPackage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashPackage.d.ts","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"hashPackage.d.ts","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAIlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKhE,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,UAAU,EAAE,UAAU,CAAC;QACvB,OAAO,EAAE,cAAc,CAAC;KACzB,CAAC;CACH,GAAG,OAAO,CAAC,MAAM,CAAC,CAgDlB"}
|
package/lib/hashPackage.js
CHANGED
|
@@ -7,7 +7,7 @@ export async function hashPackage(params) {
|
|
|
7
7
|
const start = performance.now();
|
|
8
8
|
const { input, context } = params;
|
|
9
9
|
const { packagePath, isSourceHashingEnabled } = input;
|
|
10
|
-
const { resolveMap,
|
|
10
|
+
const { resolveMap, packages, patches } = context;
|
|
11
11
|
const hashEntriesArray = [];
|
|
12
12
|
const packagesToHash = [packagePath];
|
|
13
13
|
while (packagesToHash.length > 0) {
|
|
@@ -17,16 +17,17 @@ export async function hashPackage(params) {
|
|
|
17
17
|
}
|
|
18
18
|
const hashEntries = await getPackageHashEntries({
|
|
19
19
|
options: { isSourceHashingEnabled, packagePath: packageToHash },
|
|
20
|
-
context: { packages,
|
|
20
|
+
context: { packages, patches },
|
|
21
21
|
});
|
|
22
22
|
hashEntriesArray.push(hashEntries);
|
|
23
|
-
if (
|
|
23
|
+
if (hashEntries.packageSettings.inlinedDependencies) {
|
|
24
24
|
const inlinedDependenciesPaths = getInlinedDependenciesPaths({
|
|
25
25
|
options: {
|
|
26
26
|
packageName: hashEntries.name,
|
|
27
27
|
definition: hashEntries,
|
|
28
|
+
inlinedDependencies: hashEntries.packageSettings.inlinedDependencies,
|
|
28
29
|
},
|
|
29
|
-
context: {
|
|
30
|
+
context: { resolveMap },
|
|
30
31
|
});
|
|
31
32
|
packagesToHash.push(...inlinedDependenciesPaths);
|
|
32
33
|
}
|
package/lib/hashPackage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hashPackage.js","sourceRoot":"","sources":["../src/hashPackage.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,IAA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wBAAwB,GAAG,2BAA2B,CAAC;gBAC3D,OAAO,EAAE;oBACP,WAAW,EAAE,WAAW,CAAC,IAAI;oBAC7B,UAAU,EAAE,WAAW;oBACvB,mBAAmB,EAAE,WAAW,CAAC,eAAe,CAAC,mBAAmB;iBACrE;gBACD,OAAO,EAAE,EAAE,UAAU,EAAE;aACxB,CAAC,CAAC;YACH,cAAc,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,UAAU,CAAC,gBAAgB,EAAE;QAC9C,WAAW,EAAE,KAAK;QAClB,eAAe,EAAE,IAAI;QACrB,aAAa,EAAE,IAAI;QACnB,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC9C,SAAS,IAAI,WAAW,CAAC;IACzB,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,IAAI,OAAO,OAAO,WAAW,mBAAmB,SAAS,IAAI,CAAC,CAAC;IAE3F,OAAO,IAAI,WAAW,IAAI,UAAU,EAAE,CAAC;AACzC,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport { type ResolveMap } from '@ms-cloudpack/package-utilities';\nimport objectHash from 'object-hash';\nimport { getPackageHashEntries } from './getPackageHashEntries.js';\nimport { getInlinedDependenciesPaths } from './getInlinedDependenciesPaths.js';\nimport type { PackagePatches } from './types/PackagePatches.js';\nimport { hashVersion } from './hashVersion.js';\n\nlet totalTime = 0;\n\nexport async function hashPackage(params: {\n input: {\n packagePath: string;\n isSourceHashingEnabled: boolean;\n };\n context: {\n packages: PackageDefinitionsCache;\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, 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, patches },\n });\n\n hashEntriesArray.push(hashEntries);\n\n if (hashEntries.packageSettings.inlinedDependencies) {\n const inlinedDependenciesPaths = getInlinedDependenciesPaths({\n options: {\n packageName: hashEntries.name,\n definition: hashEntries,\n inlinedDependencies: hashEntries.packageSettings.inlinedDependencies,\n },\n context: { resolveMap },\n });\n packagesToHash.push(...inlinedDependenciesPaths);\n }\n }\n\n const hashResult = objectHash(hashEntriesArray, {\n respectType: false,\n unorderedArrays: true,\n unorderedSets: true,\n unorderedObjects: true,\n ignoreUnknown: true,\n });\n\n const { name, version } = hashEntriesArray[0];\n const elapsedTime = performance.now() - start;\n totalTime += elapsedTime;\n console.debug(`Hashed ${name}@${version} in ${elapsedTime}ms, total time: ${totalTime}ms`);\n\n return `v${hashVersion}-${hashResult}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageHashOptions.d.ts","sourceRoot":"","sources":["../../src/types/PackageHashOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACE;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE;QACP,MAAM,EAAE,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"PackageHashOptions.d.ts","sourceRoot":"","sources":["../../src/types/PackageHashOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B;IACE;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;CACpB,GACD;IACE,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,EAAE;QACP,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;QACvD,QAAQ,EAAE,uBAAuB,CAAC;QAClC,UAAU,EAAE,UAAU,CAAC;KACxB,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PackageHashOptions.js","sourceRoot":"","sources":["../../src/types/PackageHashOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { HashFunction } from './HashFunction.js';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\n\n/**\n * Options for the PackageHashes class.\n */\nexport type PackageHashesOptions =\n | {\n /**\n * A function that returns the hash for a given package path. This is intended for testing purposes.\n */\n hash: HashFunction;\n }\n | {\n /** Working directory used to find the project root (usually repository root). */\n cwd: string;\n /**\n * Context for the hash calculations.\n */\n context: {\n config: CloudpackConfig
|
|
1
|
+
{"version":3,"file":"PackageHashOptions.js","sourceRoot":"","sources":["../../src/types/PackageHashOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { CloudpackConfig, PackageDefinitionsCache } from '@ms-cloudpack/common-types';\nimport type { HashFunction } from './HashFunction.js';\nimport type { ResolveMap } from '@ms-cloudpack/package-utilities';\n\n/**\n * Options for the PackageHashes class.\n */\nexport type PackageHashesOptions =\n | {\n /**\n * A function that returns the hash for a given package path. This is intended for testing purposes.\n */\n hash: HashFunction;\n }\n | {\n /** Working directory used to find the project root (usually repository root). */\n cwd: string;\n /**\n * Context for the hash calculations.\n */\n context: {\n config: Pick<CloudpackConfig, 'patchFilesGlobPattern'>;\n packages: PackageDefinitionsCache;\n resolveMap: ResolveMap;\n };\n };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/package-hashes",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.20",
|
|
4
4
|
"description": "Utilities for hashing packages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.16.
|
|
18
|
-
"@ms-cloudpack/config": "^0.26.
|
|
19
|
-
"@ms-cloudpack/package-utilities": "^9.0.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.16.1",
|
|
18
|
+
"@ms-cloudpack/config": "^0.26.2",
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^9.0.3",
|
|
20
20
|
"fast-glob": "^3.2.12",
|
|
21
21
|
"glob-hasher": "^1.4.2",
|
|
22
22
|
"object-hash": "^3.0.0"
|