@ai-primitives-hub/app 0.0.1-alpha.1 → 0.0.1-alpha.3
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/dist/collection/index.d.ts +1 -1
- package/dist/collection/index.d.ts.map +1 -1
- package/dist/collection/index.js +2 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/read-collection.d.ts +13 -0
- package/dist/collection/read-collection.d.ts.map +1 -1
- package/dist/collection/read-collection.js +40 -2
- package/dist/collection/read-collection.js.map +1 -1
- package/dist/context-detection/detector.js +4 -4
- package/dist/context-detection/detector.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/install/index.d.ts +3 -1
- package/dist/install/index.d.ts.map +1 -1
- package/dist/install/index.js +6 -1
- package/dist/install/index.js.map +1 -1
- package/dist/install/layout-resolver.d.ts +29 -1
- package/dist/install/layout-resolver.d.ts.map +1 -1
- package/dist/install/layout-resolver.js +50 -4
- package/dist/install/layout-resolver.js.map +1 -1
- package/dist/install/pipeline.d.ts.map +1 -1
- package/dist/install/pipeline.js +7 -2
- package/dist/install/pipeline.js.map +1 -1
- package/dist/install/target-write.d.ts +28 -0
- package/dist/install/target-write.d.ts.map +1 -0
- package/dist/install/target-write.js +47 -0
- package/dist/install/target-write.js.map +1 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +22 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/input-merge.d.ts +42 -0
- package/dist/mcp/input-merge.d.ts.map +1 -0
- package/dist/mcp/input-merge.js +75 -0
- package/dist/mcp/input-merge.js.map +1 -0
- package/dist/registry/activate-registry-profile.d.ts +1 -2
- package/dist/registry/activate-registry-profile.d.ts.map +1 -1
- package/dist/registry/activate-registry-profile.js.map +1 -1
- package/dist/registry/create-source-adapter.d.ts.map +1 -1
- package/dist/registry/create-source-adapter.js +6 -0
- package/dist/registry/create-source-adapter.js.map +1 -1
- package/dist/registry/deactivate-registry-profile.d.ts +1 -2
- package/dist/registry/deactivate-registry-profile.d.ts.map +1 -1
- package/dist/registry/deactivate-registry-profile.js.map +1 -1
- package/dist/registry/detect-updates.d.ts +1 -2
- package/dist/registry/detect-updates.d.ts.map +1 -1
- package/dist/registry/detect-updates.js.map +1 -1
- package/dist/registry/hydrate-source-readmes.d.ts +34 -0
- package/dist/registry/hydrate-source-readmes.d.ts.map +1 -0
- package/dist/registry/hydrate-source-readmes.js +57 -0
- package/dist/registry/hydrate-source-readmes.js.map +1 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +3 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/install-registry-bundle.d.ts +1 -2
- package/dist/registry/install-registry-bundle.d.ts.map +1 -1
- package/dist/registry/install-registry-bundle.js.map +1 -1
- package/dist/registry/list-all-profiles.d.ts +1 -2
- package/dist/registry/list-all-profiles.d.ts.map +1 -1
- package/dist/registry/list-all-profiles.js.map +1 -1
- package/dist/registry/load-hub-sources.d.ts +35 -3
- package/dist/registry/load-hub-sources.d.ts.map +1 -1
- package/dist/registry/load-hub-sources.js +63 -6
- package/dist/registry/load-hub-sources.js.map +1 -1
- package/dist/registry/profile-lifecycle.d.ts +1 -2
- package/dist/registry/profile-lifecycle.d.ts.map +1 -1
- package/dist/registry/profile-lifecycle.js.map +1 -1
- package/dist/registry/registry-settings.d.ts +1 -2
- package/dist/registry/registry-settings.d.ts.map +1 -1
- package/dist/registry/registry-settings.js +2 -35
- package/dist/registry/registry-settings.js.map +1 -1
- package/dist/registry/resolve-installation-bundle.d.ts +1 -2
- package/dist/registry/resolve-installation-bundle.d.ts.map +1 -1
- package/dist/registry/resolve-installation-bundle.js.map +1 -1
- package/dist/registry/search-registry-bundles.d.ts +1 -2
- package/dist/registry/search-registry-bundles.d.ts.map +1 -1
- package/dist/registry/search-registry-bundles.js.map +1 -1
- package/dist/registry/source-sync-queue.d.ts +22 -0
- package/dist/registry/source-sync-queue.d.ts.map +1 -0
- package/dist/registry/source-sync-queue.js +75 -0
- package/dist/registry/source-sync-queue.js.map +1 -0
- package/dist/registry/uninstall-installed-bundle.d.ts +1 -2
- package/dist/registry/uninstall-installed-bundle.d.ts.map +1 -1
- package/dist/registry/uninstall-installed-bundle.js.map +1 -1
- package/dist/registry/update-registry-bundle.d.ts +1 -2
- package/dist/registry/update-registry-bundle.d.ts.map +1 -1
- package/dist/registry/update-registry-bundle.js.map +1 -1
- package/dist/registry/validate-hub-config-file.d.ts +104 -0
- package/dist/registry/validate-hub-config-file.d.ts.map +1 -0
- package/dist/registry/validate-hub-config-file.js +541 -0
- package/dist/registry/validate-hub-config-file.js.map +1 -0
- package/dist/registry/version-consolidator.d.ts +1 -2
- package/dist/registry/version-consolidator.d.ts.map +1 -1
- package/dist/registry/version-consolidator.js.map +1 -1
- package/dist/search/build-index.d.ts +63 -0
- package/dist/search/build-index.d.ts.map +1 -0
- package/dist/search/build-index.js +107 -0
- package/dist/search/build-index.js.map +1 -0
- package/dist/search/bundle-search-keys.d.ts +35 -0
- package/dist/search/bundle-search-keys.d.ts.map +1 -0
- package/dist/search/bundle-search-keys.js +49 -0
- package/dist/search/bundle-search-keys.js.map +1 -0
- package/dist/search/index-location.d.ts +29 -0
- package/dist/search/index-location.d.ts.map +1 -0
- package/dist/search/index-location.js +32 -0
- package/dist/search/index-location.js.map +1 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +6 -0
- package/dist/search/index.js.map +1 -1
- package/dist/search/primitive-search.d.ts +100 -0
- package/dist/search/primitive-search.d.ts.map +1 -0
- package/dist/search/primitive-search.js +99 -0
- package/dist/search/primitive-search.js.map +1 -0
- package/dist/search/search-index.d.ts +47 -0
- package/dist/search/search-index.d.ts.map +1 -0
- package/dist/search/search-index.js +110 -0
- package/dist/search/search-index.js.map +1 -0
- package/dist/search/search-profile.d.ts +41 -0
- package/dist/search/search-profile.d.ts.map +1 -0
- package/dist/search/search-profile.js +61 -0
- package/dist/search/search-profile.js.map +1 -0
- package/dist/stores/json-lockfile-store.d.ts +9 -2
- package/dist/stores/json-lockfile-store.d.ts.map +1 -1
- package/dist/stores/json-lockfile-store.js +6 -1
- package/dist/stores/json-lockfile-store.js.map +1 -1
- package/dist/update/auto-update.d.ts +1 -2
- package/dist/update/auto-update.d.ts.map +1 -1
- package/dist/update/auto-update.js.map +1 -1
- package/dist/update/check-updates.d.ts +3 -3
- package/dist/update/check-updates.d.ts.map +1 -1
- package/dist/update/check-updates.js +3 -2
- package/dist/update/check-updates.js.map +1 -1
- package/dist/update/index.d.ts +6 -1
- package/dist/update/index.d.ts.map +1 -1
- package/dist/update/index.js +0 -1
- package/dist/update/index.js.map +1 -1
- package/dist/writers/file-tree-writer.d.ts +50 -7
- package/dist/writers/file-tree-writer.d.ts.map +1 -1
- package/dist/writers/file-tree-writer.js +209 -78
- package/dist/writers/file-tree-writer.js.map +1 -1
- package/package.json +8 -8
- package/dist/update/log-event.d.ts +0 -15
- package/dist/update/log-event.d.ts.map +0 -1
- package/dist/update/log-event.js +0 -11
- package/dist/update/log-event.js.map +0 -1
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
* the current installation, before resolving the new bundle version.
|
|
12
12
|
* @module registry/update-registry-bundle
|
|
13
13
|
*/
|
|
14
|
-
import type { Bundle, InstallationScope, InstalledBundle, RegistrySource, SourceAdapter, SourceType } from '@ai-primitives-hub/core';
|
|
15
|
-
import type { OnLogEvent } from '../update/log-event';
|
|
14
|
+
import type { Bundle, InstallationScope, InstalledBundle, OnLogEvent, RegistrySource, SourceAdapter, SourceType } from '@ai-primitives-hub/core';
|
|
16
15
|
/** Read/write access `updateRegistryBundle` needs. */
|
|
17
16
|
export interface UpdateRegistryBundlePorts {
|
|
18
17
|
listInstalledBundles(): Promise<InstalledBundle[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-registry-bundle.d.ts","sourceRoot":"","sources":["../../src/registry/update-registry-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,
|
|
1
|
+
{"version":3,"file":"update-registry-bundle.d.ts","sourceRoot":"","sources":["../../src/registry/update-registry-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,eAAe,EAEf,UAAU,EACV,cAAc,EACd,aAAa,EACb,UAAU,EACX,MAAM,yBAAyB,CAAC;AAKjC,sDAAsD;AACtD,MAAM,WAAW,yBAAyB;IACxC,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IACnD,uBAAuB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACzC,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,CAAC;IAClD,qBAAqB,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACxI,kBAAkB,CAAC,YAAY,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/E;AAMD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,yBAAyB,EAChC,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,eAAe,CAAC,CAiE1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-registry-bundle.js","sourceRoot":"","sources":["../../src/registry/update-registry-bundle.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"update-registry-bundle.js","sourceRoot":"","sources":["../../src/registry/update-registry-bundle.ts"],"names":[],"mappings":";;AAmDA,oDAsEC;AAlGD,kDAEiC;AAcjC,SAAS,GAAG,CAAC,KAA6B,EAAE,KAAwB,EAAE,OAAe,EAAE,KAAa;IAClG,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,QAAgB,EAChB,OAA2B,EAC3B,KAAgC,EAChC,KAAkB;IAElB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,oBAAoB,QAAQ,gBAAgB,OAAO,IAAI,QAAQ,EAAE,CAAC,CAAC;IAEtF,2FAA2F;IAC3F,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IAElE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,WAAW,QAAQ,oBAAoB,CAAC,CAAC;IAC3D,CAAC;IAED,+EAA+E;IAC/E,MAAM,KAAK,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAA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nD,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;YAC9C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,WAAW,iCAAiC,QAAQ,GAAG,CAAC,CAAC;YACvF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YACtD,6BAA6B;YAC7B,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,0BAA0B,QAAQ,GAAG,CAAC,CAAC;YACrF,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IAED,yEAAyE;IACzE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACtD,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,6BAA6B,QAAQ,OAAO,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAChG,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,uDAAuD;QACvD,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,+BAA+B,QAAQ,6BAA6B,QAAQ,GAAG,CAAC,CAAC;QACrG,OAAO,MAAM,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate a hub-config YAML file from a repository working tree.
|
|
3
|
+
*
|
|
4
|
+
* The app layer coordinates file access and the infra boundary validator;
|
|
5
|
+
* parsing and policy logic remain below the delivery layer so the CLI and
|
|
6
|
+
* future authoring integrations use the same behavior.
|
|
7
|
+
* @module registry/validate-hub-config-file
|
|
8
|
+
*/
|
|
9
|
+
import type { FileSystem, ValidationResult } from '@ai-primitives-hub/core';
|
|
10
|
+
import { type SourceAdapterFactoryDeps } from './create-source-adapter';
|
|
11
|
+
export interface HubConfigFileValidationResult extends ValidationResult {
|
|
12
|
+
file: string;
|
|
13
|
+
}
|
|
14
|
+
export interface HubCatalogBundle {
|
|
15
|
+
id: string;
|
|
16
|
+
version: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HubSourceDeepValidationResult extends ValidationResult {
|
|
19
|
+
sourceId: string;
|
|
20
|
+
sourceType: string;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
bundles: HubCatalogBundle[];
|
|
23
|
+
skipped?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface HubProfileBundleDeepValidationResult {
|
|
26
|
+
sourceId: string;
|
|
27
|
+
bundleId: string;
|
|
28
|
+
requestedVersion: string;
|
|
29
|
+
required: boolean;
|
|
30
|
+
valid: boolean;
|
|
31
|
+
resolvedBundle?: HubCatalogBundle;
|
|
32
|
+
errors: string[];
|
|
33
|
+
warnings: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface HubProfileDeepValidationResult {
|
|
36
|
+
profileId: string;
|
|
37
|
+
valid: boolean;
|
|
38
|
+
bundles: HubProfileBundleDeepValidationResult[];
|
|
39
|
+
errors: string[];
|
|
40
|
+
warnings: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface DeepHubConfigValidationResult extends HubConfigFileValidationResult {
|
|
43
|
+
deep: true;
|
|
44
|
+
sources: HubSourceDeepValidationResult[];
|
|
45
|
+
profiles: HubProfileDeepValidationResult[];
|
|
46
|
+
bundlesFound: number;
|
|
47
|
+
}
|
|
48
|
+
export type HubValidationProgress = {
|
|
49
|
+
phase: 'started';
|
|
50
|
+
sourcesTotal: number;
|
|
51
|
+
profilesTotal: number;
|
|
52
|
+
} | {
|
|
53
|
+
phase: 'source';
|
|
54
|
+
status: 'started' | 'completed';
|
|
55
|
+
current: number;
|
|
56
|
+
total: number;
|
|
57
|
+
sourceId: string;
|
|
58
|
+
sourceType: string;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
valid?: boolean;
|
|
61
|
+
bundlesFound?: number;
|
|
62
|
+
skipped?: boolean;
|
|
63
|
+
} | {
|
|
64
|
+
phase: 'catalog';
|
|
65
|
+
status: 'started' | 'completed';
|
|
66
|
+
current: number;
|
|
67
|
+
total: number;
|
|
68
|
+
sourceId: string;
|
|
69
|
+
sourceType: string;
|
|
70
|
+
bundlesFound?: number;
|
|
71
|
+
} | {
|
|
72
|
+
phase: 'profile';
|
|
73
|
+
status: 'started' | 'completed';
|
|
74
|
+
current: number;
|
|
75
|
+
total: number;
|
|
76
|
+
profileId: string;
|
|
77
|
+
bundlesTotal: number;
|
|
78
|
+
valid?: boolean;
|
|
79
|
+
errors?: number;
|
|
80
|
+
warnings?: number;
|
|
81
|
+
} | {
|
|
82
|
+
phase: 'completed';
|
|
83
|
+
sourcesTotal: number;
|
|
84
|
+
profilesTotal: number;
|
|
85
|
+
bundlesFound: number;
|
|
86
|
+
valid: boolean;
|
|
87
|
+
};
|
|
88
|
+
export interface HubConfigFileValidationOptions {
|
|
89
|
+
/** Perform source accessibility, catalog discovery, and profile resolution checks. */
|
|
90
|
+
deep?: boolean;
|
|
91
|
+
/** Dependencies used to construct the configured source adapters. */
|
|
92
|
+
sourceAdapterDeps?: SourceAdapterFactoryDeps;
|
|
93
|
+
/** Receive deterministic progress events during deep validation. */
|
|
94
|
+
onProgress?: (event: HubValidationProgress) => void;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Read and validate one hub configuration file.
|
|
98
|
+
* @param fs Filesystem port used to read the repository file.
|
|
99
|
+
* @param filePath Absolute or repository-relative file path.
|
|
100
|
+
* @param options
|
|
101
|
+
* @returns File path and combined validation result.
|
|
102
|
+
*/
|
|
103
|
+
export declare function validateHubConfigFile(fs: FileSystem, filePath: string, options?: HubConfigFileValidationOptions): Promise<HubConfigFileValidationResult | DeepHubConfigValidationResult>;
|
|
104
|
+
//# sourceMappingURL=validate-hub-config-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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AC;CAChB,CAAC;AAEJ,MAAM,WAAW,8BAA8B;IAC7C,sFAAsF;IACtF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,oEAAoE;IACpE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACrD;AASD;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,8BAAmC,GAC3C,OAAO,CAAC,6BAA6B,GAAG,6BAA6B,CAAC,CAqDxE"}
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateHubConfigFile = validateHubConfigFile;
|
|
4
|
+
const core_1 = require("@ai-primitives-hub/core");
|
|
5
|
+
const infra_1 = require("@ai-primitives-hub/infra");
|
|
6
|
+
const create_source_adapter_1 = require("./create-source-adapter");
|
|
7
|
+
const failure = (file, message) => ({
|
|
8
|
+
file,
|
|
9
|
+
valid: false,
|
|
10
|
+
errors: [message],
|
|
11
|
+
warnings: []
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Read and validate one hub configuration file.
|
|
15
|
+
* @param fs Filesystem port used to read the repository file.
|
|
16
|
+
* @param filePath Absolute or repository-relative file path.
|
|
17
|
+
* @param options
|
|
18
|
+
* @returns File path and combined validation result.
|
|
19
|
+
*/
|
|
20
|
+
async function validateHubConfigFile(fs, filePath, options = {}) {
|
|
21
|
+
let content;
|
|
22
|
+
try {
|
|
23
|
+
content = await fs.readFile(filePath);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return failure(filePath, `Unable to read hub configuration '${filePath}': ${error instanceof Error ? error.message : String(error)}`);
|
|
27
|
+
}
|
|
28
|
+
let config;
|
|
29
|
+
try {
|
|
30
|
+
config = (0, infra_1.parseHubConfigYaml)(content);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return failure(filePath, `YAML parse error in '${filePath}': ${error instanceof Error ? error.message : String(error)}`);
|
|
34
|
+
}
|
|
35
|
+
const staticResult = {
|
|
36
|
+
file: filePath,
|
|
37
|
+
...(0, infra_1.validateHubConfigDocument)(config)
|
|
38
|
+
};
|
|
39
|
+
if (!options.deep) {
|
|
40
|
+
return staticResult;
|
|
41
|
+
}
|
|
42
|
+
if (!options.sourceAdapterDeps) {
|
|
43
|
+
return {
|
|
44
|
+
...staticResult,
|
|
45
|
+
deep: true,
|
|
46
|
+
sources: [],
|
|
47
|
+
profiles: [],
|
|
48
|
+
bundlesFound: 0,
|
|
49
|
+
valid: false,
|
|
50
|
+
errors: [...staticResult.errors, 'Deep validation requires source adapter dependencies.']
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (!staticResult.valid) {
|
|
54
|
+
return {
|
|
55
|
+
...staticResult,
|
|
56
|
+
deep: true,
|
|
57
|
+
sources: [],
|
|
58
|
+
profiles: [],
|
|
59
|
+
bundlesFound: 0
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return validateHubConfigDeep(config, filePath, options.sourceAdapterDeps, options.onProgress);
|
|
63
|
+
}
|
|
64
|
+
const isRecord = (value) => (value !== null && typeof value === 'object' && !Array.isArray(value));
|
|
65
|
+
const asString = (value, fallback) => (typeof value === 'string' ? value : fallback);
|
|
66
|
+
const sourceTypeFrom = (value) => {
|
|
67
|
+
if (typeof value !== 'string') {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
};
|
|
72
|
+
function toRegistrySource(value) {
|
|
73
|
+
const id = typeof value.id === 'string' ? value.id : undefined;
|
|
74
|
+
const type = sourceTypeFrom(value.type);
|
|
75
|
+
const url = typeof value.url === 'string'
|
|
76
|
+
? value.url
|
|
77
|
+
: (typeof value.repository === 'string'
|
|
78
|
+
? `https://github.com/${value.repository}`
|
|
79
|
+
: undefined);
|
|
80
|
+
if (!id || !type || !url) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const config = isRecord(value.config) ? value.config : undefined;
|
|
84
|
+
const topLevelBranch = typeof value.branch === 'string' ? value.branch : undefined;
|
|
85
|
+
const normalizedConfig = topLevelBranch === undefined || config?.branch !== undefined
|
|
86
|
+
? config
|
|
87
|
+
: { ...config, branch: topLevelBranch };
|
|
88
|
+
return {
|
|
89
|
+
id,
|
|
90
|
+
name: asString(value.name, id),
|
|
91
|
+
type,
|
|
92
|
+
url,
|
|
93
|
+
enabled: value.enabled === true,
|
|
94
|
+
priority: typeof value.priority === 'number' ? value.priority : 0,
|
|
95
|
+
private: value.private === true,
|
|
96
|
+
token: typeof value.token === 'string' ? value.token : undefined,
|
|
97
|
+
metadata: isRecord(value.metadata) ? value.metadata : undefined,
|
|
98
|
+
config: normalizedConfig
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function bundleMatchesReference(bundle, reference, sourceType) {
|
|
102
|
+
if (bundle.id === reference.id) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
if (sourceType !== 'github') {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return (0, core_1.extractBundleIdentity)(bundle.id, sourceType) === (0, core_1.extractBundleIdentity)(reference.id, sourceType);
|
|
109
|
+
}
|
|
110
|
+
function compareCatalogVersions(left, right) {
|
|
111
|
+
try {
|
|
112
|
+
const versionOrder = (0, core_1.compareVersions)(right.version, left.version);
|
|
113
|
+
if (versionOrder !== 0) {
|
|
114
|
+
return versionOrder;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
const versionOrder = right.version.localeCompare(left.version);
|
|
119
|
+
if (versionOrder !== 0) {
|
|
120
|
+
return versionOrder;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return left.id.localeCompare(right.id);
|
|
124
|
+
}
|
|
125
|
+
function sortBundles(bundles) {
|
|
126
|
+
return bundles.toSorted((left, right) => {
|
|
127
|
+
const idOrder = left.id.localeCompare(right.id);
|
|
128
|
+
if (idOrder !== 0) {
|
|
129
|
+
return idOrder;
|
|
130
|
+
}
|
|
131
|
+
return compareCatalogVersions({ id: left.id, version: left.version }, { id: right.id, version: right.version });
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function selectLatestBundle(bundles) {
|
|
135
|
+
return bundles
|
|
136
|
+
.toSorted((left, right) => compareCatalogVersions({ id: left.id, version: left.version }, { id: right.id, version: right.version }))[0];
|
|
137
|
+
}
|
|
138
|
+
function availableVersions(bundles) {
|
|
139
|
+
return [...new Set(bundles.map((bundle) => bundle.version))]
|
|
140
|
+
.toSorted((left, right) => {
|
|
141
|
+
try {
|
|
142
|
+
return (0, core_1.compareVersions)(left, right);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return left.localeCompare(right);
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
.join(', ');
|
|
149
|
+
}
|
|
150
|
+
async function validateSource(source, deps, onProgress, current, total) {
|
|
151
|
+
onProgress?.({
|
|
152
|
+
phase: 'source',
|
|
153
|
+
status: 'started',
|
|
154
|
+
current,
|
|
155
|
+
total,
|
|
156
|
+
sourceId: source.id,
|
|
157
|
+
sourceType: source.type,
|
|
158
|
+
enabled: source.enabled
|
|
159
|
+
});
|
|
160
|
+
if (!source.enabled) {
|
|
161
|
+
onProgress?.({
|
|
162
|
+
phase: 'source',
|
|
163
|
+
status: 'completed',
|
|
164
|
+
current,
|
|
165
|
+
total,
|
|
166
|
+
sourceId: source.id,
|
|
167
|
+
sourceType: source.type,
|
|
168
|
+
enabled: false,
|
|
169
|
+
valid: true,
|
|
170
|
+
bundlesFound: 0,
|
|
171
|
+
skipped: true
|
|
172
|
+
});
|
|
173
|
+
return {
|
|
174
|
+
source,
|
|
175
|
+
bundles: [],
|
|
176
|
+
result: {
|
|
177
|
+
sourceId: source.id,
|
|
178
|
+
sourceType: source.type,
|
|
179
|
+
enabled: false,
|
|
180
|
+
valid: true,
|
|
181
|
+
errors: [],
|
|
182
|
+
warnings: ['Source is disabled; accessibility and catalog checks were skipped.'],
|
|
183
|
+
bundles: [],
|
|
184
|
+
bundlesFound: 0,
|
|
185
|
+
skipped: true
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
let adapter;
|
|
190
|
+
try {
|
|
191
|
+
adapter = (0, create_source_adapter_1.createSourceAdapter)(source, deps);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
195
|
+
onProgress?.({
|
|
196
|
+
phase: 'source',
|
|
197
|
+
status: 'completed',
|
|
198
|
+
current,
|
|
199
|
+
total,
|
|
200
|
+
sourceId: source.id,
|
|
201
|
+
sourceType: source.type,
|
|
202
|
+
enabled: true,
|
|
203
|
+
valid: false,
|
|
204
|
+
bundlesFound: 0
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
source,
|
|
208
|
+
bundles: [],
|
|
209
|
+
result: {
|
|
210
|
+
sourceId: source.id,
|
|
211
|
+
sourceType: source.type,
|
|
212
|
+
enabled: true,
|
|
213
|
+
valid: false,
|
|
214
|
+
errors: [`Failed to create source adapter: ${message}`],
|
|
215
|
+
warnings: [],
|
|
216
|
+
bundles: [],
|
|
217
|
+
bundlesFound: 0
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
let validation;
|
|
222
|
+
try {
|
|
223
|
+
validation = await adapter.validate();
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
227
|
+
validation = {
|
|
228
|
+
valid: false,
|
|
229
|
+
errors: [`Source validation failed: ${message}`],
|
|
230
|
+
warnings: []
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
if (!validation.valid) {
|
|
234
|
+
onProgress?.({
|
|
235
|
+
phase: 'source',
|
|
236
|
+
status: 'completed',
|
|
237
|
+
current,
|
|
238
|
+
total,
|
|
239
|
+
sourceId: source.id,
|
|
240
|
+
sourceType: source.type,
|
|
241
|
+
enabled: true,
|
|
242
|
+
valid: false,
|
|
243
|
+
bundlesFound: 0
|
|
244
|
+
});
|
|
245
|
+
return {
|
|
246
|
+
source,
|
|
247
|
+
bundles: [],
|
|
248
|
+
result: {
|
|
249
|
+
sourceId: source.id,
|
|
250
|
+
sourceType: source.type,
|
|
251
|
+
enabled: true,
|
|
252
|
+
valid: false,
|
|
253
|
+
errors: validation.errors,
|
|
254
|
+
warnings: validation.warnings ?? [],
|
|
255
|
+
bundles: [],
|
|
256
|
+
bundlesFound: 0
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
onProgress?.({
|
|
261
|
+
phase: 'catalog',
|
|
262
|
+
status: 'started',
|
|
263
|
+
current,
|
|
264
|
+
total,
|
|
265
|
+
sourceId: source.id,
|
|
266
|
+
sourceType: source.type
|
|
267
|
+
});
|
|
268
|
+
let bundles;
|
|
269
|
+
try {
|
|
270
|
+
bundles = sortBundles(await adapter.fetchBundles());
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
274
|
+
onProgress?.({
|
|
275
|
+
phase: 'catalog',
|
|
276
|
+
status: 'completed',
|
|
277
|
+
current,
|
|
278
|
+
total,
|
|
279
|
+
sourceId: source.id,
|
|
280
|
+
sourceType: source.type,
|
|
281
|
+
bundlesFound: 0
|
|
282
|
+
});
|
|
283
|
+
onProgress?.({
|
|
284
|
+
phase: 'source',
|
|
285
|
+
status: 'completed',
|
|
286
|
+
current,
|
|
287
|
+
total,
|
|
288
|
+
sourceId: source.id,
|
|
289
|
+
sourceType: source.type,
|
|
290
|
+
enabled: true,
|
|
291
|
+
valid: false,
|
|
292
|
+
bundlesFound: 0
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
source,
|
|
296
|
+
bundles: [],
|
|
297
|
+
result: {
|
|
298
|
+
sourceId: source.id,
|
|
299
|
+
sourceType: source.type,
|
|
300
|
+
enabled: true,
|
|
301
|
+
valid: false,
|
|
302
|
+
errors: [`Failed to discover bundles: ${message}`],
|
|
303
|
+
warnings: validation.warnings ?? [],
|
|
304
|
+
bundles: [],
|
|
305
|
+
bundlesFound: 0
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const catalog = bundles.map(({ id, version }) => ({ id, version }));
|
|
310
|
+
onProgress?.({
|
|
311
|
+
phase: 'catalog',
|
|
312
|
+
status: 'completed',
|
|
313
|
+
current,
|
|
314
|
+
total,
|
|
315
|
+
sourceId: source.id,
|
|
316
|
+
sourceType: source.type,
|
|
317
|
+
bundlesFound: bundles.length
|
|
318
|
+
});
|
|
319
|
+
onProgress?.({
|
|
320
|
+
phase: 'source',
|
|
321
|
+
status: 'completed',
|
|
322
|
+
current,
|
|
323
|
+
total,
|
|
324
|
+
sourceId: source.id,
|
|
325
|
+
sourceType: source.type,
|
|
326
|
+
enabled: true,
|
|
327
|
+
valid: true,
|
|
328
|
+
bundlesFound: bundles.length
|
|
329
|
+
});
|
|
330
|
+
return {
|
|
331
|
+
source,
|
|
332
|
+
bundles,
|
|
333
|
+
result: {
|
|
334
|
+
sourceId: source.id,
|
|
335
|
+
sourceType: source.type,
|
|
336
|
+
enabled: true,
|
|
337
|
+
valid: true,
|
|
338
|
+
errors: [],
|
|
339
|
+
warnings: validation.warnings ?? [],
|
|
340
|
+
bundles: catalog,
|
|
341
|
+
bundlesFound: bundles.length
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function resolveProfileBundle(profileId, reference, catalog) {
|
|
346
|
+
const base = {
|
|
347
|
+
sourceId: reference.source,
|
|
348
|
+
bundleId: reference.id,
|
|
349
|
+
requestedVersion: reference.version,
|
|
350
|
+
required: reference.required
|
|
351
|
+
};
|
|
352
|
+
const diagnostic = (message) => ({
|
|
353
|
+
...base,
|
|
354
|
+
valid: !reference.required,
|
|
355
|
+
errors: reference.required ? [message] : [],
|
|
356
|
+
warnings: reference.required ? [] : [message]
|
|
357
|
+
});
|
|
358
|
+
if (!catalog) {
|
|
359
|
+
return diagnostic(`Profile '${profileId}' references unknown source '${reference.source}'.`);
|
|
360
|
+
}
|
|
361
|
+
if (!catalog.source.enabled) {
|
|
362
|
+
return diagnostic(`Profile '${profileId}' references disabled source '${reference.source}'.`);
|
|
363
|
+
}
|
|
364
|
+
if (!catalog.result.valid) {
|
|
365
|
+
return diagnostic(`Profile '${profileId}' cannot resolve bundle '${reference.id}' because source '${reference.source}' failed validation.`);
|
|
366
|
+
}
|
|
367
|
+
const candidates = catalog.bundles.filter((bundle) => bundleMatchesReference(bundle, reference, catalog.source.type));
|
|
368
|
+
if (candidates.length === 0) {
|
|
369
|
+
return diagnostic(`Profile '${profileId}' references bundle '${reference.id}' from source '${reference.source}', `
|
|
370
|
+
+ 'but no matching bundle was discovered.');
|
|
371
|
+
}
|
|
372
|
+
if (reference.version === 'latest') {
|
|
373
|
+
const latest = selectLatestBundle(candidates);
|
|
374
|
+
if (!latest) {
|
|
375
|
+
return diagnostic(`Profile '${profileId}' references bundle '${reference.id}' from source '${reference.source}', but no matching bundle was discovered.`);
|
|
376
|
+
}
|
|
377
|
+
return {
|
|
378
|
+
...base,
|
|
379
|
+
valid: true,
|
|
380
|
+
resolvedBundle: { id: latest.id, version: latest.version },
|
|
381
|
+
errors: [],
|
|
382
|
+
warnings: []
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
const exactVersion = candidates.find((bundle) => bundle.version === reference.version);
|
|
386
|
+
if (!exactVersion) {
|
|
387
|
+
return diagnostic(`Profile '${profileId}' requires bundle '${reference.id}' at version '${reference.version}' `
|
|
388
|
+
+ `from source '${reference.source}', but available versions are: ${availableVersions(candidates)}.`);
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
...base,
|
|
392
|
+
valid: true,
|
|
393
|
+
resolvedBundle: { id: exactVersion.id, version: exactVersion.version },
|
|
394
|
+
errors: [],
|
|
395
|
+
warnings: []
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
async function validateHubConfigDeep(config, filePath, deps, onProgress) {
|
|
399
|
+
const root = config;
|
|
400
|
+
const sourceValues = Array.isArray(root.sources) ? root.sources.filter((value) => isRecord(value)) : [];
|
|
401
|
+
const sourceEntries = sourceValues
|
|
402
|
+
.map((value, index) => ({ value, index, id: asString(value.id, `#${index + 1}`) }))
|
|
403
|
+
.toSorted((left, right) => left.id.localeCompare(right.id));
|
|
404
|
+
const profileValues = Array.isArray(root.profiles) ? root.profiles.filter((value) => isRecord(value)) : [];
|
|
405
|
+
const profileEntries = profileValues
|
|
406
|
+
.map((value, index) => ({ value, index, id: asString(value.id, `#${index + 1}`) }))
|
|
407
|
+
.toSorted((left, right) => left.id.localeCompare(right.id));
|
|
408
|
+
const catalogs = new Map();
|
|
409
|
+
onProgress?.({
|
|
410
|
+
phase: 'started',
|
|
411
|
+
sourcesTotal: sourceEntries.length,
|
|
412
|
+
profilesTotal: profileEntries.length
|
|
413
|
+
});
|
|
414
|
+
for (const [sourceIndex, entry] of sourceEntries.entries()) {
|
|
415
|
+
const source = toRegistrySource(entry.value);
|
|
416
|
+
if (!source) {
|
|
417
|
+
const sourceType = asString(entry.value.type, 'unknown');
|
|
418
|
+
onProgress?.({
|
|
419
|
+
phase: 'source',
|
|
420
|
+
status: 'started',
|
|
421
|
+
current: sourceIndex + 1,
|
|
422
|
+
total: sourceEntries.length,
|
|
423
|
+
sourceId: entry.id,
|
|
424
|
+
sourceType,
|
|
425
|
+
enabled: entry.value.enabled === true
|
|
426
|
+
});
|
|
427
|
+
catalogs.set(entry.id, {
|
|
428
|
+
source: {
|
|
429
|
+
id: entry.id,
|
|
430
|
+
name: entry.id,
|
|
431
|
+
type: sourceType,
|
|
432
|
+
url: '',
|
|
433
|
+
enabled: entry.value.enabled === true,
|
|
434
|
+
priority: typeof entry.value.priority === 'number' ? entry.value.priority : 0
|
|
435
|
+
},
|
|
436
|
+
bundles: [],
|
|
437
|
+
result: {
|
|
438
|
+
sourceId: entry.id,
|
|
439
|
+
sourceType,
|
|
440
|
+
enabled: entry.value.enabled === true,
|
|
441
|
+
valid: false,
|
|
442
|
+
errors: [`Source '${entry.id}' must define a supported type and URL for deep validation.`],
|
|
443
|
+
warnings: [],
|
|
444
|
+
bundles: [],
|
|
445
|
+
bundlesFound: 0
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
onProgress?.({
|
|
449
|
+
phase: 'source',
|
|
450
|
+
status: 'completed',
|
|
451
|
+
current: sourceIndex + 1,
|
|
452
|
+
total: sourceEntries.length,
|
|
453
|
+
sourceId: entry.id,
|
|
454
|
+
sourceType,
|
|
455
|
+
enabled: entry.value.enabled === true,
|
|
456
|
+
valid: false,
|
|
457
|
+
bundlesFound: 0
|
|
458
|
+
});
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
catalogs.set(entry.id, await validateSource(source, deps, onProgress, sourceIndex + 1, sourceEntries.length));
|
|
462
|
+
}
|
|
463
|
+
const sourceResults = sourceEntries.map((entry) => catalogs.get(entry.id).result);
|
|
464
|
+
const profileResults = profileEntries.map((entry, profileIndex) => {
|
|
465
|
+
const rawBundles = Array.isArray(entry.value.bundles)
|
|
466
|
+
? entry.value.bundles.filter((value) => isRecord(value))
|
|
467
|
+
: [];
|
|
468
|
+
const references = rawBundles
|
|
469
|
+
.map((value) => ({
|
|
470
|
+
id: asString(value.id, ''),
|
|
471
|
+
version: asString(value.version, ''),
|
|
472
|
+
source: asString(value.source, ''),
|
|
473
|
+
required: value.required === true
|
|
474
|
+
}))
|
|
475
|
+
.toSorted((left, right) => {
|
|
476
|
+
const sourceOrder = left.source.localeCompare(right.source);
|
|
477
|
+
if (sourceOrder !== 0) {
|
|
478
|
+
return sourceOrder;
|
|
479
|
+
}
|
|
480
|
+
const idOrder = left.id.localeCompare(right.id);
|
|
481
|
+
if (idOrder !== 0) {
|
|
482
|
+
return idOrder;
|
|
483
|
+
}
|
|
484
|
+
return left.version.localeCompare(right.version);
|
|
485
|
+
});
|
|
486
|
+
onProgress?.({
|
|
487
|
+
phase: 'profile',
|
|
488
|
+
status: 'started',
|
|
489
|
+
current: profileIndex + 1,
|
|
490
|
+
total: profileEntries.length,
|
|
491
|
+
profileId: entry.id,
|
|
492
|
+
bundlesTotal: references.length
|
|
493
|
+
});
|
|
494
|
+
const bundleResults = references.map((reference) => resolveProfileBundle(entry.id, reference, catalogs.get(reference.source)));
|
|
495
|
+
const profileResult = {
|
|
496
|
+
profileId: entry.id,
|
|
497
|
+
valid: bundleResults.every((bundle) => bundle.valid),
|
|
498
|
+
bundles: bundleResults,
|
|
499
|
+
errors: bundleResults.flatMap((bundle) => bundle.errors),
|
|
500
|
+
warnings: bundleResults.flatMap((bundle) => bundle.warnings)
|
|
501
|
+
};
|
|
502
|
+
onProgress?.({
|
|
503
|
+
phase: 'profile',
|
|
504
|
+
status: 'completed',
|
|
505
|
+
current: profileIndex + 1,
|
|
506
|
+
total: profileEntries.length,
|
|
507
|
+
profileId: entry.id,
|
|
508
|
+
bundlesTotal: references.length,
|
|
509
|
+
valid: profileResult.valid,
|
|
510
|
+
errors: profileResult.errors.length,
|
|
511
|
+
warnings: profileResult.warnings.length
|
|
512
|
+
});
|
|
513
|
+
return profileResult;
|
|
514
|
+
});
|
|
515
|
+
const sourceErrors = sourceResults.flatMap((source) => source.errors);
|
|
516
|
+
const profileErrors = profileResults.flatMap((profile) => profile.errors);
|
|
517
|
+
const warnings = [
|
|
518
|
+
...sourceResults.flatMap((source) => source.warnings ?? []),
|
|
519
|
+
...profileResults.flatMap((profile) => profile.warnings)
|
|
520
|
+
];
|
|
521
|
+
const bundlesFound = sourceResults.reduce((total, source) => total + (source.bundlesFound ?? 0), 0);
|
|
522
|
+
const valid = sourceErrors.length === 0 && profileErrors.length === 0;
|
|
523
|
+
onProgress?.({
|
|
524
|
+
phase: 'completed',
|
|
525
|
+
sourcesTotal: sourceEntries.length,
|
|
526
|
+
profilesTotal: profileEntries.length,
|
|
527
|
+
bundlesFound,
|
|
528
|
+
valid
|
|
529
|
+
});
|
|
530
|
+
return {
|
|
531
|
+
file: filePath,
|
|
532
|
+
deep: true,
|
|
533
|
+
valid,
|
|
534
|
+
errors: [...sourceErrors, ...profileErrors],
|
|
535
|
+
warnings,
|
|
536
|
+
sources: sourceResults,
|
|
537
|
+
profiles: profileResults,
|
|
538
|
+
bundlesFound
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
//# sourceMappingURL=validate-hub-config-file.js.map
|