@g3nomaly/core 0.3.0 → 0.3.2
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/LICENSE +95 -0
- package/dist/cli/commands/add.d.ts +37 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +99 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/conflict.d.ts +52 -0
- package/dist/cli/commands/conflict.d.ts.map +1 -0
- package/dist/cli/commands/conflict.js +88 -0
- package/dist/cli/commands/conflict.js.map +1 -0
- package/dist/cli/commands/installFromSources.d.ts +78 -0
- package/dist/cli/commands/installFromSources.d.ts.map +1 -0
- package/dist/cli/commands/installFromSources.js +187 -0
- package/dist/cli/commands/installFromSources.js.map +1 -0
- package/dist/cli/commands/ls.d.ts +26 -0
- package/dist/cli/commands/ls.d.ts.map +1 -0
- package/dist/cli/commands/ls.js +85 -0
- package/dist/cli/commands/ls.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +19 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +123 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/commands/sources.d.ts +69 -0
- package/dist/cli/commands/sources.d.ts.map +1 -0
- package/dist/cli/commands/sources.js +103 -0
- package/dist/cli/commands/sources.js.map +1 -0
- package/dist/cli/commands/update.d.ts +17 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +110 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/dialogue.d.ts +126 -0
- package/dist/cli/dialogue.d.ts.map +1 -0
- package/dist/cli/dialogue.js +156 -0
- package/dist/cli/dialogue.js.map +1 -0
- package/dist/cli/index.d.ts +19 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +16 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/installDialogues.d.ts +23 -0
- package/dist/cli/installDialogues.d.ts.map +1 -0
- package/dist/cli/installDialogues.js +89 -0
- package/dist/cli/installDialogues.js.map +1 -0
- package/dist/cli/pick.d.ts +23 -0
- package/dist/cli/pick.d.ts.map +1 -0
- package/dist/cli/pick.js +44 -0
- package/dist/cli/pick.js.map +1 -0
- package/dist/cli/report.d.ts +58 -0
- package/dist/cli/report.d.ts.map +1 -0
- package/dist/cli/report.js +92 -0
- package/dist/cli/report.js.map +1 -0
- package/dist/cli/theme.d.ts +27 -0
- package/dist/cli/theme.d.ts.map +1 -0
- package/dist/cli/theme.js +29 -0
- package/dist/cli/theme.js.map +1 -0
- package/dist/cli/types.d.ts +96 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config/config.d.ts +55 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +107 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +182 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +51 -0
- package/dist/config/types.js.map +1 -0
- package/dist/hash/hash.d.ts +23 -0
- package/dist/hash/hash.d.ts.map +1 -0
- package/dist/hash/hash.js +43 -0
- package/dist/hash/hash.js.map +1 -0
- package/dist/hash/index.d.ts +2 -0
- package/dist/hash/index.d.ts.map +1 -0
- package/dist/hash/index.js +3 -0
- package/dist/hash/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/classify.d.ts +33 -0
- package/dist/installer/classify.d.ts.map +1 -0
- package/dist/installer/classify.js +82 -0
- package/dist/installer/classify.js.map +1 -0
- package/dist/installer/files.d.ts +19 -0
- package/dist/installer/files.d.ts.map +1 -0
- package/dist/installer/files.js +23 -0
- package/dist/installer/files.js.map +1 -0
- package/dist/installer/index.d.ts +19 -0
- package/dist/installer/index.d.ts.map +1 -0
- package/dist/installer/index.js +14 -0
- package/dist/installer/index.js.map +1 -0
- package/dist/installer/install.d.ts +25 -0
- package/dist/installer/install.d.ts.map +1 -0
- package/dist/installer/install.js +74 -0
- package/dist/installer/install.js.map +1 -0
- package/dist/installer/io.d.ts +9 -0
- package/dist/installer/io.d.ts.map +1 -0
- package/dist/installer/io.js +23 -0
- package/dist/installer/io.js.map +1 -0
- package/dist/installer/manifest.d.ts +69 -0
- package/dist/installer/manifest.d.ts.map +1 -0
- package/dist/installer/manifest.js +70 -0
- package/dist/installer/manifest.js.map +1 -0
- package/dist/installer/manifestSources.d.ts +32 -0
- package/dist/installer/manifestSources.d.ts.map +1 -0
- package/dist/installer/manifestSources.js +50 -0
- package/dist/installer/manifestSources.js.map +1 -0
- package/dist/installer/marketplace.d.ts +46 -0
- package/dist/installer/marketplace.d.ts.map +1 -0
- package/dist/installer/marketplace.js +72 -0
- package/dist/installer/marketplace.js.map +1 -0
- package/dist/installer/origin.d.ts +59 -0
- package/dist/installer/origin.d.ts.map +1 -0
- package/dist/installer/origin.js +29 -0
- package/dist/installer/origin.js.map +1 -0
- package/dist/installer/remove.d.ts +26 -0
- package/dist/installer/remove.d.ts.map +1 -0
- package/dist/installer/remove.js +49 -0
- package/dist/installer/remove.js.map +1 -0
- package/dist/installer/resolve.d.ts +127 -0
- package/dist/installer/resolve.d.ts.map +1 -0
- package/dist/installer/resolve.js +251 -0
- package/dist/installer/resolve.js.map +1 -0
- package/dist/installer/sourceRegistry.d.ts +96 -0
- package/dist/installer/sourceRegistry.d.ts.map +1 -0
- package/dist/installer/sourceRegistry.js +86 -0
- package/dist/installer/sourceRegistry.js.map +1 -0
- package/dist/installer/types.d.ts +133 -0
- package/dist/installer/types.d.ts.map +1 -0
- package/dist/installer/types.js +31 -0
- package/dist/installer/types.js.map +1 -0
- package/dist/registry/index.d.ts +8 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +9 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.handlers.d.ts +16 -0
- package/dist/registry/registry.handlers.d.ts.map +1 -0
- package/dist/registry/registry.handlers.js +13 -0
- package/dist/registry/registry.handlers.js.map +1 -0
- package/dist/registry/registry.io.d.ts +38 -0
- package/dist/registry/registry.io.d.ts.map +1 -0
- package/dist/registry/registry.io.js +101 -0
- package/dist/registry/registry.io.js.map +1 -0
- package/dist/registry/registry.mutations.d.ts +19 -0
- package/dist/registry/registry.mutations.d.ts.map +1 -0
- package/dist/registry/registry.mutations.js +29 -0
- package/dist/registry/registry.mutations.js.map +1 -0
- package/dist/registry/registry.selectors.d.ts +68 -0
- package/dist/registry/registry.selectors.d.ts.map +1 -0
- package/dist/registry/registry.selectors.js +91 -0
- package/dist/registry/registry.selectors.js.map +1 -0
- package/dist/registry/registry.store.d.ts +47 -0
- package/dist/registry/registry.store.d.ts.map +1 -0
- package/dist/registry/registry.store.js +36 -0
- package/dist/registry/registry.store.js.map +1 -0
- package/dist/registry/registry.template.d.ts +29 -0
- package/dist/registry/registry.template.d.ts.map +1 -0
- package/dist/registry/registry.template.js +70 -0
- package/dist/registry/registry.template.js.map +1 -0
- package/dist/registry/types.d.ts +47 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +35 -0
- package/dist/registry/types.js.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +3 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/securityParser.d.ts +15 -0
- package/dist/security/securityParser.d.ts.map +1 -0
- package/dist/security/securityParser.js +79 -0
- package/dist/security/securityParser.js.map +1 -0
- package/dist/security/securityWorker.d.ts +19 -0
- package/dist/security/securityWorker.d.ts.map +1 -0
- package/dist/security/securityWorker.js +137 -0
- package/dist/security/securityWorker.js.map +1 -0
- package/dist/sources/checkout.d.ts +20 -0
- package/dist/sources/checkout.d.ts.map +1 -0
- package/dist/sources/checkout.js +33 -0
- package/dist/sources/checkout.js.map +1 -0
- package/dist/sources/git.d.ts +11 -0
- package/dist/sources/git.d.ts.map +1 -0
- package/dist/sources/git.js +24 -0
- package/dist/sources/git.js.map +1 -0
- package/dist/sources/index.d.ts +5 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +6 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/local.d.ts +12 -0
- package/dist/sources/local.d.ts.map +1 -0
- package/dist/sources/local.js +22 -0
- package/dist/sources/local.js.map +1 -0
- package/dist/sources/npm.d.ts +16 -0
- package/dist/sources/npm.d.ts.map +1 -0
- package/dist/sources/npm.js +162 -0
- package/dist/sources/npm.js.map +1 -0
- package/dist/sources/packageJson.d.ts +3 -0
- package/dist/sources/packageJson.d.ts.map +1 -0
- package/dist/sources/packageJson.js +13 -0
- package/dist/sources/packageJson.js.map +1 -0
- package/dist/sources/parse.d.ts +42 -0
- package/dist/sources/parse.d.ts.map +1 -0
- package/dist/sources/parse.js +114 -0
- package/dist/sources/parse.js.map +1 -0
- package/dist/sources/process.d.ts +21 -0
- package/dist/sources/process.d.ts.map +1 -0
- package/dist/sources/process.js +46 -0
- package/dist/sources/process.js.map +1 -0
- package/dist/sources/register.d.ts +31 -0
- package/dist/sources/register.d.ts.map +1 -0
- package/dist/sources/register.js +52 -0
- package/dist/sources/register.js.map +1 -0
- package/dist/sources/types.d.ts +108 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +53 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +11 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/merge.d.ts +12 -0
- package/dist/utils/merge.d.ts.map +1 -0
- package/dist/utils/merge.js +28 -0
- package/dist/utils/merge.js.map +1 -0
- package/dist/utils/packageMeta.d.ts +26 -0
- package/dist/utils/packageMeta.d.ts.map +1 -0
- package/dist/utils/packageMeta.js +24 -0
- package/dist/utils/packageMeta.js.map +1 -0
- package/dist/utils/paths.d.ts +27 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +51 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/prompt.d.ts +8 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +13 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/version.d.ts +14 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +140 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +64 -3
- package/README.md +0 -3
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type RegistryStore } from "../registry/registry.store";
|
|
2
|
+
import type { RegisteredSource, SourceCheckout } from "../sources/types";
|
|
3
|
+
import type { EntrySource } from "../cli/types";
|
|
4
|
+
import { type OriginEntry } from "./origin";
|
|
5
|
+
/**
|
|
6
|
+
* @brief What a package's reader found in one checked-out source.
|
|
7
|
+
*
|
|
8
|
+
* @property entries - Entries by key, each with its `origin` filled in.
|
|
9
|
+
* @property warnings - Problems the reader met that did not stop it.
|
|
10
|
+
*/
|
|
11
|
+
export interface SourceEntries<T extends OriginEntry> {
|
|
12
|
+
entries: [string, T][];
|
|
13
|
+
warnings: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @brief Reads the entries one checked-out source offers. Each installer supplies its own.
|
|
17
|
+
*
|
|
18
|
+
* @param checkout - Checkout of the source to read.
|
|
19
|
+
* @returns Entries and warnings found in the checkout.
|
|
20
|
+
*/
|
|
21
|
+
export type ReadSource<T extends OriginEntry> = (checkout: SourceCheckout) => Promise<SourceEntries<T>>;
|
|
22
|
+
/**
|
|
23
|
+
* @brief A source that could not be checked out or read.
|
|
24
|
+
*
|
|
25
|
+
* @property name - Name of the registered source.
|
|
26
|
+
* @property error - Reason it failed, as a message.
|
|
27
|
+
*/
|
|
28
|
+
export interface FailedSource {
|
|
29
|
+
name: string;
|
|
30
|
+
error: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @brief The entries a set of sources offers, one registry store per source.
|
|
34
|
+
*
|
|
35
|
+
* Checkouts stay on disk until `dispose` so the install can copy files out of them. Built by
|
|
36
|
+
* `loadSourceRegistry` in each installer's `add`, `update`, `ls` and `source add` commands. `offers`
|
|
37
|
+
* lists every entry for name resolution, and `entrySource` copies an entry's files from its checkout.
|
|
38
|
+
*
|
|
39
|
+
* @property sources - Entries by source name, in the order the sources were given.
|
|
40
|
+
* @property checkouts - Checkout of each source by name.
|
|
41
|
+
* @property warnings - Warnings from loading, prefixed with the source name.
|
|
42
|
+
* @property failed - Sources that could not be checked out or read.
|
|
43
|
+
* @property dispose - Releases every checkout.
|
|
44
|
+
*/
|
|
45
|
+
export interface SourceRegistry<T extends OriginEntry> {
|
|
46
|
+
sources: Map<string, RegistryStore<T>>;
|
|
47
|
+
checkouts: Map<string, SourceCheckout>;
|
|
48
|
+
warnings: string[];
|
|
49
|
+
failed: FailedSource[];
|
|
50
|
+
dispose: () => void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* @brief One entry that one source offers.
|
|
54
|
+
*
|
|
55
|
+
* @property key - Key of the entry within its source.
|
|
56
|
+
* @property entry - The entry itself.
|
|
57
|
+
*/
|
|
58
|
+
export interface SourceOffer<T extends OriginEntry> {
|
|
59
|
+
key: string;
|
|
60
|
+
entry: T;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @brief Checks out each source and reads its entries with `readSource`, all sources at once.
|
|
64
|
+
*
|
|
65
|
+
* A source that cannot be checked out or read lands in `failed` instead of throwing, so one unreachable
|
|
66
|
+
* source does not stop the rest. A key offered twice by one source keeps the first, with a warning.
|
|
67
|
+
*
|
|
68
|
+
* @param sources - Registered sources to load.
|
|
69
|
+
* @param projectRoot - Absolute root that local source paths and the `node_modules` lookup start from.
|
|
70
|
+
* @param readSource - Reads the entries of one checkout.
|
|
71
|
+
* @returns Registry holding every source that loaded, with the rest in `failed`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function loadSourceRegistry<T extends OriginEntry>(sources: readonly RegisteredSource[], projectRoot: string, readSource: ReadSource<T>): Promise<SourceRegistry<T>>;
|
|
74
|
+
/**
|
|
75
|
+
* @brief Lists every entry of every source, sources in their given order and keys sorted within each.
|
|
76
|
+
*
|
|
77
|
+
* @param registry - Registry returned by `loadSourceRegistry`.
|
|
78
|
+
* @returns One offer per entry.
|
|
79
|
+
*/
|
|
80
|
+
export declare function offers<T extends OriginEntry>(registry: SourceRegistry<T>): SourceOffer<T>[];
|
|
81
|
+
/**
|
|
82
|
+
* @brief File source for the core install commands. Copies each file from `<checkout>/<origin.dir>/<path>` in its entry's source.
|
|
83
|
+
*
|
|
84
|
+
* @param registry - Registry whose checkouts the files are copied from.
|
|
85
|
+
* @returns Source that copies an entry's files from the checkout of `origin.source`.
|
|
86
|
+
* @throws {Error} When the entry's source is not checked out.
|
|
87
|
+
*/
|
|
88
|
+
export declare function entrySource<T extends OriginEntry>(registry: SourceRegistry<T>): EntrySource;
|
|
89
|
+
/**
|
|
90
|
+
* @brief Converts offers into the registry the core install commands take, keyed by entry key.
|
|
91
|
+
*
|
|
92
|
+
* @param selected - Offers to include. A later offer with the same key replaces an earlier one.
|
|
93
|
+
* @returns Entries by key.
|
|
94
|
+
*/
|
|
95
|
+
export declare function offerRegistry<T extends OriginEntry>(selected: Iterable<SourceOffer<T>>): Record<string, T>;
|
|
96
|
+
//# sourceMappingURL=sourceRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceRegistry.d.ts","sourceRoot":"","sources":["../../src/installer/sourceRegistry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAA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ACxB,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CA6B5B;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAG3F;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,WAAW,CAO3F;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAI1G"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// packages/core/src/installer/sourceRegistry.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createRegistryStore } from "../registry/registry.store";
|
|
4
|
+
import { register } from "../registry/registry.mutations";
|
|
5
|
+
import { entries } from "../registry/registry.selectors";
|
|
6
|
+
import { checkoutSource } from "../sources/checkout";
|
|
7
|
+
import { errorMessage } from "../utils/errors";
|
|
8
|
+
import { copySource } from "./install";
|
|
9
|
+
import { OriginEntrySchema } from "./origin";
|
|
10
|
+
/**
|
|
11
|
+
* @brief Checks out each source and reads its entries with `readSource`, all sources at once.
|
|
12
|
+
*
|
|
13
|
+
* A source that cannot be checked out or read lands in `failed` instead of throwing, so one unreachable
|
|
14
|
+
* source does not stop the rest. A key offered twice by one source keeps the first, with a warning.
|
|
15
|
+
*
|
|
16
|
+
* @param sources - Registered sources to load.
|
|
17
|
+
* @param projectRoot - Absolute root that local source paths and the `node_modules` lookup start from.
|
|
18
|
+
* @param readSource - Reads the entries of one checkout.
|
|
19
|
+
* @returns Registry holding every source that loaded, with the rest in `failed`.
|
|
20
|
+
*/
|
|
21
|
+
export async function loadSourceRegistry(sources, projectRoot, readSource) {
|
|
22
|
+
const registry = { sources: new Map(), checkouts: new Map(), warnings: [], failed: [], dispose: () => { } };
|
|
23
|
+
registry.dispose = () => { for (const checkout of registry.checkouts.values())
|
|
24
|
+
checkout.dispose(); };
|
|
25
|
+
const results = await Promise.allSettled(sources.map(async (source) => {
|
|
26
|
+
const checkout = await checkoutSource(source, projectRoot);
|
|
27
|
+
registry.checkouts.set(source.name, checkout);
|
|
28
|
+
return readSource(checkout);
|
|
29
|
+
}));
|
|
30
|
+
results.forEach((result, index) => {
|
|
31
|
+
const name = sources[index]?.name ?? "";
|
|
32
|
+
if (result.status === "rejected") {
|
|
33
|
+
registry.failed.push({ name, error: errorMessage(result.reason) });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const store = createRegistryStore();
|
|
37
|
+
for (const [key, entry] of result.value.entries) {
|
|
38
|
+
if (store.store.state[key] !== undefined) {
|
|
39
|
+
registry.warnings.push(`${name}: "${key}" is offered twice, using the first`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
register(store, key, entry);
|
|
43
|
+
}
|
|
44
|
+
registry.sources.set(name, store);
|
|
45
|
+
registry.warnings.push(...result.value.warnings.map((warning) => `${name}: ${warning}`));
|
|
46
|
+
});
|
|
47
|
+
return registry;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @brief Lists every entry of every source, sources in their given order and keys sorted within each.
|
|
51
|
+
*
|
|
52
|
+
* @param registry - Registry returned by `loadSourceRegistry`.
|
|
53
|
+
* @returns One offer per entry.
|
|
54
|
+
*/
|
|
55
|
+
export function offers(registry) {
|
|
56
|
+
return [...registry.sources.values()].flatMap((store) => Object.entries(entries(store)).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => ({ key, entry })));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @brief File source for the core install commands. Copies each file from `<checkout>/<origin.dir>/<path>` in its entry's source.
|
|
60
|
+
*
|
|
61
|
+
* @param registry - Registry whose checkouts the files are copied from.
|
|
62
|
+
* @returns Source that copies an entry's files from the checkout of `origin.source`.
|
|
63
|
+
* @throws {Error} When the entry's source is not checked out.
|
|
64
|
+
*/
|
|
65
|
+
export function entrySource(registry) {
|
|
66
|
+
return (entry) => {
|
|
67
|
+
const { origin } = OriginEntrySchema.pick({ origin: true }).parse(entry);
|
|
68
|
+
const checkout = registry.checkouts.get(origin.source);
|
|
69
|
+
if (checkout === undefined)
|
|
70
|
+
throw new Error(`source ${origin.source} of "${entry.name}" is not checked out`);
|
|
71
|
+
return copySource((filePath) => path.join(checkout.dir, origin.dir, filePath));
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @brief Converts offers into the registry the core install commands take, keyed by entry key.
|
|
76
|
+
*
|
|
77
|
+
* @param selected - Offers to include. A later offer with the same key replaces an earlier one.
|
|
78
|
+
* @returns Entries by key.
|
|
79
|
+
*/
|
|
80
|
+
export function offerRegistry(selected) {
|
|
81
|
+
const registry = {};
|
|
82
|
+
for (const offer of selected)
|
|
83
|
+
registry[offer.key] = offer.entry;
|
|
84
|
+
return registry;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=sourceRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceRegistry.js","sourceRoot":"","sources":["../../src/installer/sourceRegistry.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAsB,MAAM,4BAA4B,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAA;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO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WAAW,CAAwB,QAA2B;IAC5E,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,EAAE,MAAM,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACxE,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACtD,IAAI,QAAQ,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,CAAC,MAAM,QAAQ,KAAK,CAAC,IAAI,sBAAsB,CAAC,CAAA;QAC5G,OAAO,UAAU,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAA;IAChF,CAAC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAwB,QAAkC;IACrF,MAAM,QAAQ,GAAsB,EAAE,CAAA;IACtC,KAAK,MAAM,KAAK,IAAI,QAAQ;QAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAA;IAC/D,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { BaseFileEntry } from "../registry/types";
|
|
2
|
+
/**
|
|
3
|
+
* @brief Relation of one installed file to its package version, ordered by severity.
|
|
4
|
+
*
|
|
5
|
+
* Const object standing in for an enum. Every state from `UserOnly` up carries local changes.
|
|
6
|
+
*
|
|
7
|
+
* @property UpToDate - On disk and identical to the package file.
|
|
8
|
+
* @property SafeUpdate - Missing, or unmodified while the package file changed. Writable without data loss.
|
|
9
|
+
* @property UserOnly - Modified locally while the package file is unchanged.
|
|
10
|
+
* @property Conflict - Modified locally and the package file changed too.
|
|
11
|
+
*/
|
|
12
|
+
export declare const FileState: {
|
|
13
|
+
readonly UpToDate: 0;
|
|
14
|
+
readonly SafeUpdate: 1;
|
|
15
|
+
readonly UserOnly: 2;
|
|
16
|
+
readonly Conflict: 3;
|
|
17
|
+
};
|
|
18
|
+
/** One of the `FileState` values. */
|
|
19
|
+
export type FileState = (typeof FileState)[keyof typeof FileState];
|
|
20
|
+
/**
|
|
21
|
+
* @brief Choice for an entry whose files have local changes (`UserOnly` and `Conflict`).
|
|
22
|
+
*
|
|
23
|
+
* Const object standing in for an enum. `remove` offers only `Keep` and `Overwrite`.
|
|
24
|
+
*
|
|
25
|
+
* @property Keep - Skip: leave the changed files alone and keep their install-time hash, so the next run asks again.
|
|
26
|
+
* @property Overwrite - Restore: write the source version over the changes.
|
|
27
|
+
* @property Fork - Keep the files as they are under a new key that no update touches.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ConflictDecision: {
|
|
30
|
+
readonly Keep: 0;
|
|
31
|
+
readonly Overwrite: 1;
|
|
32
|
+
readonly Fork: 2;
|
|
33
|
+
};
|
|
34
|
+
/** One of the `ConflictDecision` values. */
|
|
35
|
+
export type ConflictDecision = (typeof ConflictDecision)[keyof typeof ConflictDecision];
|
|
36
|
+
/**
|
|
37
|
+
* @brief Classification of one file, produced by `classifyFiles` and consumed by `applyClassifications`.
|
|
38
|
+
*
|
|
39
|
+
* @property file - Registry entry of the file, with the hash the package ships.
|
|
40
|
+
* @property destPath - Absolute path the file is installed at: `installDir` joined with `file.path`.
|
|
41
|
+
* @property state - What the install or update does with the file.
|
|
42
|
+
* @property exists - Whether a file is on disk at `destPath`.
|
|
43
|
+
* @property currentHash - Hash of the file on disk, e.g. `"a1b2"`. `null` when it does not exist.
|
|
44
|
+
* @property recordedHash - Hash recorded in the user manifest at install time. `undefined` when never installed.
|
|
45
|
+
* @property latestHash - Hash of the package's current version of the file.
|
|
46
|
+
*/
|
|
47
|
+
export interface FileClassification<F extends BaseFileEntry = BaseFileEntry> {
|
|
48
|
+
file: F;
|
|
49
|
+
destPath: string;
|
|
50
|
+
state: FileState;
|
|
51
|
+
exists: boolean;
|
|
52
|
+
currentHash: string | null;
|
|
53
|
+
recordedHash: string | undefined;
|
|
54
|
+
latestHash: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Where a file's content comes from when it is written. `null` skips the file.
|
|
58
|
+
*/
|
|
59
|
+
export type FileContent = {
|
|
60
|
+
kind: "copy";
|
|
61
|
+
sourcePath: string;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "write";
|
|
64
|
+
content: string;
|
|
65
|
+
} | null;
|
|
66
|
+
/**
|
|
67
|
+
* @brief Produces the content of one file for `applyClassifications`.
|
|
68
|
+
*
|
|
69
|
+
* @param file - Registry entry of the file to produce content for.
|
|
70
|
+
* @returns Where the content comes from, or `null` to skip the file.
|
|
71
|
+
*/
|
|
72
|
+
export type FileSource<F extends BaseFileEntry = BaseFileEntry> = (file: F) => FileContent | Promise<FileContent>;
|
|
73
|
+
/**
|
|
74
|
+
* @brief Filesystem boundary for the installer. `createInstallerIO` supplies the real implementation; tests inject stubs per field.
|
|
75
|
+
*
|
|
76
|
+
* @property exists - Whether a path exists on disk.
|
|
77
|
+
* @property ensureDir - Creates a directory and its parents when missing.
|
|
78
|
+
* @property copyFile - Copies the file at `src` to `dest`.
|
|
79
|
+
* @property writeFile - Writes `content` to `dest` as UTF-8.
|
|
80
|
+
* @property removeFile - Deletes the file at `path`.
|
|
81
|
+
* @property listDir - Names of the entries directly inside `dir`.
|
|
82
|
+
* @property removeDir - Deletes `dir` and everything below it.
|
|
83
|
+
* @property hashFile - Content hash of the file at `path`.
|
|
84
|
+
*/
|
|
85
|
+
export interface InstallerIO {
|
|
86
|
+
exists: (path: string) => boolean;
|
|
87
|
+
ensureDir: (dir: string) => void;
|
|
88
|
+
copyFile: (src: string, dest: string) => void;
|
|
89
|
+
writeFile: (dest: string, content: string) => void;
|
|
90
|
+
removeFile: (path: string) => void;
|
|
91
|
+
listDir: (dir: string) => string[];
|
|
92
|
+
removeDir: (dir: string) => void;
|
|
93
|
+
hashFile: (path: string) => Promise<string>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @brief Options that decide which changed files `applyClassifications` writes.
|
|
97
|
+
*
|
|
98
|
+
* @property decision - What to do with entries that have local changes.
|
|
99
|
+
* @property force - Writes changed files even when `decision` is not `Overwrite`.
|
|
100
|
+
* @property dryRun - Reports the result without touching the disk.
|
|
101
|
+
*/
|
|
102
|
+
export interface ApplyOptions {
|
|
103
|
+
decision: ConflictDecision;
|
|
104
|
+
force?: boolean;
|
|
105
|
+
dryRun?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* @brief Outcome of `applyClassifications`, per file.
|
|
109
|
+
*
|
|
110
|
+
* @property written - Relative paths written, or that would be written under `dryRun`.
|
|
111
|
+
* @property kept - Relative paths with local changes that were left alone.
|
|
112
|
+
* @property missingSource - Relative paths whose source produced no content.
|
|
113
|
+
* @property files - Manifest entries reflecting the on-disk state after the apply.
|
|
114
|
+
*/
|
|
115
|
+
export interface ApplyResult<F extends BaseFileEntry = BaseFileEntry> {
|
|
116
|
+
written: string[];
|
|
117
|
+
kept: string[];
|
|
118
|
+
missingSource: string[];
|
|
119
|
+
files: F[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @brief Outcome of removing installed files.
|
|
123
|
+
*
|
|
124
|
+
* @property removed - Relative paths deleted.
|
|
125
|
+
* @property kept - Relative paths with local changes that were left alone.
|
|
126
|
+
* @property missing - Relative paths that were not on disk.
|
|
127
|
+
*/
|
|
128
|
+
export interface RemoveResult {
|
|
129
|
+
removed: string[];
|
|
130
|
+
kept: string[];
|
|
131
|
+
missing: string[];
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/installer/types.ts"],"names":[],"mappings":"AACA,OA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|
|
3
|
+
*
|
|
4
|
+
* Const object standing in for an enum. Every state from `UserOnly` up carries local changes.
|
|
5
|
+
*
|
|
6
|
+
* @property UpToDate - On disk and identical to the package file.
|
|
7
|
+
* @property SafeUpdate - Missing, or unmodified while the package file changed. Writable without data loss.
|
|
8
|
+
* @property UserOnly - Modified locally while the package file is unchanged.
|
|
9
|
+
* @property Conflict - Modified locally and the package file changed too.
|
|
10
|
+
*/
|
|
11
|
+
export const FileState = {
|
|
12
|
+
UpToDate: 0,
|
|
13
|
+
SafeUpdate: 1,
|
|
14
|
+
UserOnly: 2,
|
|
15
|
+
Conflict: 3,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @brief Choice for an entry whose files have local changes (`UserOnly` and `Conflict`).
|
|
19
|
+
*
|
|
20
|
+
* Const object standing in for an enum. `remove` offers only `Keep` and `Overwrite`.
|
|
21
|
+
*
|
|
22
|
+
* @property Keep - Skip: leave the changed files alone and keep their install-time hash, so the next run asks again.
|
|
23
|
+
* @property Overwrite - Restore: write the source version over the changes.
|
|
24
|
+
* @property Fork - Keep the files as they are under a new key that no update touches.
|
|
25
|
+
*/
|
|
26
|
+
export const ConflictDecision = {
|
|
27
|
+
Keep: 0,
|
|
28
|
+
Overwrite: 1,
|
|
29
|
+
Fork: 2,
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/installer/types.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAI,CAAC;IACb,UAAU,EAAE,CAAC;IACb,QAAQ,EAAI,CAAC;IACb,QAAQ,EAAI,CAAC;CACL,CAAA;AAIV;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAO,CAAC;IACZ,SAAS,EAAE,CAAC;IACZ,IAAI,EAAO,CAAC;CACJ,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./registry.handlers";
|
|
3
|
+
export * from "./registry.store";
|
|
4
|
+
export * from "./registry.mutations";
|
|
5
|
+
export * from "./registry.selectors";
|
|
6
|
+
export * from "./registry.template";
|
|
7
|
+
export * from "./registry.io";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// packages/core/src/registry/index.ts
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./registry.handlers";
|
|
4
|
+
export * from "./registry.store";
|
|
5
|
+
export * from "./registry.mutations";
|
|
6
|
+
export * from "./registry.selectors";
|
|
7
|
+
export * from "./registry.template";
|
|
8
|
+
export * from "./registry.io";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BaseRegistry, BaseRegistryEntry } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* @brief Converts a registry map to and from the text of a manifest file.
|
|
4
|
+
*
|
|
5
|
+
* @property extensions - File extensions this handler reads and writes, without the dot, e.g. `json`.
|
|
6
|
+
* @property serialize - Turns the registry map into file text.
|
|
7
|
+
* @property deserialize - Parses file text back into a registry map.
|
|
8
|
+
*/
|
|
9
|
+
export interface RegistryHandler<T extends BaseRegistryEntry = BaseRegistryEntry> {
|
|
10
|
+
extensions: string[];
|
|
11
|
+
serialize: (data: BaseRegistry<T>) => string;
|
|
12
|
+
deserialize: (raw: string) => BaseRegistry<T>;
|
|
13
|
+
}
|
|
14
|
+
export declare const tsHandler: RegistryHandler<any>;
|
|
15
|
+
export declare const jsonHandler: RegistryHandler<any>;
|
|
16
|
+
//# sourceMappingURL=registry.handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.handlers.d.ts","sourceRoot":"","sources":["../../src/registry/registry.handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE9D;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB;IAC9E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM,CAAA;IAC5C,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,YAAY,CAAC,CAAC,CAAC,CAAA;CAC9C;AAED,eAAO,MAAM,SAAS,EAAE,eAAe,CAAC,GAAG,CAO1C,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,eAAe,CAAC,GAAG,CAI5C,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const tsHandler = {
|
|
2
|
+
extensions: ["ts"],
|
|
3
|
+
serialize: (data) => `export const registry = ${JSON.stringify(data, null, 2)} as const\n`,
|
|
4
|
+
deserialize: () => {
|
|
5
|
+
throw new Error("TS handler deserializes via dynamic import — use load()");
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
export const jsonHandler = {
|
|
9
|
+
extensions: ["json"],
|
|
10
|
+
serialize: (data) => JSON.stringify(data, null, 2),
|
|
11
|
+
deserialize: (raw) => JSON.parse(raw),
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=registry.handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.handlers.js","sourceRoot":"","sources":["../../src/registry/registry.handlers.ts"],"names":[],"mappings":"AAgBA,MAAM,CAAC,MAAM,SAAS,GAAyB;IAC7C,UAAU,EAAE,CAAC,IAAI,CAAC;IAClB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,2BAA2B,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,aAAa;IACvE,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;IAC5E,CAAC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAyB;IAC/C,UAAU,EAAE,CAAC,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,WAAW,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;CACtC,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BaseRegistryEntry } from "./types";
|
|
2
|
+
import type { RegistryStore } from "./registry.store";
|
|
3
|
+
import type { RegistryHandler } from "./registry.handlers";
|
|
4
|
+
/**
|
|
5
|
+
* @brief Alias of `load()` that takes an explicit file path. Behaves the same.
|
|
6
|
+
*
|
|
7
|
+
* @param registry - Store to hydrate.
|
|
8
|
+
* @param filePath - Absolute path to read from.
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadFrom<T extends BaseRegistryEntry>(registry: RegistryStore<T>, filePath: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* @brief Hydrates the store from a file.
|
|
13
|
+
*
|
|
14
|
+
* A `.ts` file is read by dynamic import, which skips the handler, since such a file exports a `registry`
|
|
15
|
+
* object directly at runtime. Any other file is read with `readFileSync` and `handler.deserialize`.
|
|
16
|
+
* Does nothing when there is no file path or the file does not exist yet.
|
|
17
|
+
*
|
|
18
|
+
* @param registry - Store to hydrate.
|
|
19
|
+
* @param filePath - File to read. Defaults to the store's bound `filePath`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function load<T extends BaseRegistryEntry>(registry: RegistryStore<T>, filePath?: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* @brief Writes the store to its bound `filePath`, entries sorted by key.
|
|
24
|
+
*
|
|
25
|
+
* @param registry - Store to write.
|
|
26
|
+
* @param handler - Serialization handler. Defaults to the store's handler, then `tsHandler`.
|
|
27
|
+
* @throws {Error} When the store has no bound `filePath`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function flush<T extends BaseRegistryEntry>(registry: RegistryStore<T>, handler?: RegistryHandler<T>): void;
|
|
30
|
+
/**
|
|
31
|
+
* @brief Writes the store to an explicit path, entries sorted by key. The store's bound `filePath` is not changed.
|
|
32
|
+
*
|
|
33
|
+
* @param registry - Store to write.
|
|
34
|
+
* @param filePath - Absolute path to write to.
|
|
35
|
+
* @param handler - Serialization handler. Defaults to the store's handler, then `tsHandler`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function writeTo<T extends BaseRegistryEntry>(registry: RegistryStore<T>, filePath: string, handler?: RegistryHandler<T>): void;
|
|
38
|
+
//# sourceMappingURL=registry.io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.io.d.ts","sourceRoot":"","sources":["../../src/registry/registry.io.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAqC1D;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EACxD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAEf;AAMD;;;;;;;;;GASG;AACH,wBAAsB,IAAI,CAAC,CAAC,SAAS,iBAAiB,EACpD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAgBf;AAMD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,iBAAiB,EAC/C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC3B,IAAI,CASN;AAMD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,iBAAiB,EACjD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC3B,IAAI,CAGN"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// packages/core/src/registry/registry.io.ts
|
|
2
|
+
import { writeFileSync, readFileSync } from "node:fs";
|
|
3
|
+
import { tsHandler } from "./registry.handlers";
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Helpers
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/**
|
|
8
|
+
* @brief Picks the handler for a read or write: the override, then the store's handler, then `tsHandler`.
|
|
9
|
+
*
|
|
10
|
+
* @param registry - Store whose handler is the fallback.
|
|
11
|
+
* @param override - Handler passed by the caller, if any.
|
|
12
|
+
* @returns The handler to use.
|
|
13
|
+
*/
|
|
14
|
+
function resolveHandler(registry, override) {
|
|
15
|
+
return override ?? registry.handler ?? tsHandler;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* @brief Returns the store's entries sorted by key, for deterministic output.
|
|
19
|
+
*
|
|
20
|
+
* @param registry - Store to read from.
|
|
21
|
+
* @returns Entries by key, in alphabetical key order.
|
|
22
|
+
*/
|
|
23
|
+
function sortedEntries(registry) {
|
|
24
|
+
return Object.fromEntries(Object.entries(registry.store.state).sort(([a], [b]) => a.localeCompare(b)));
|
|
25
|
+
}
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// loadFrom (file → store)
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
/**
|
|
30
|
+
* @brief Alias of `load()` that takes an explicit file path. Behaves the same.
|
|
31
|
+
*
|
|
32
|
+
* @param registry - Store to hydrate.
|
|
33
|
+
* @param filePath - Absolute path to read from.
|
|
34
|
+
*/
|
|
35
|
+
export async function loadFrom(registry, filePath) {
|
|
36
|
+
return load(registry, filePath);
|
|
37
|
+
}
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// load (file → store)
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
/**
|
|
42
|
+
* @brief Hydrates the store from a file.
|
|
43
|
+
*
|
|
44
|
+
* A `.ts` file is read by dynamic import, which skips the handler, since such a file exports a `registry`
|
|
45
|
+
* object directly at runtime. Any other file is read with `readFileSync` and `handler.deserialize`.
|
|
46
|
+
* Does nothing when there is no file path or the file does not exist yet.
|
|
47
|
+
*
|
|
48
|
+
* @param registry - Store to hydrate.
|
|
49
|
+
* @param filePath - File to read. Defaults to the store's bound `filePath`.
|
|
50
|
+
*/
|
|
51
|
+
export async function load(registry, filePath) {
|
|
52
|
+
const target = filePath ?? registry.filePath;
|
|
53
|
+
if (!target)
|
|
54
|
+
return;
|
|
55
|
+
try {
|
|
56
|
+
if (target.endsWith(".ts")) {
|
|
57
|
+
const mod = (await import(`file://${target}`));
|
|
58
|
+
registry.store.setState(() => ({ ...mod.registry }));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const h = resolveHandler(registry);
|
|
62
|
+
const raw = readFileSync(target, "utf-8");
|
|
63
|
+
registry.store.setState(() => ({ ...h.deserialize(raw) }));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// File doesn't exist yet — store stays empty
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// flush (store → bound filePath)
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
/**
|
|
74
|
+
* @brief Writes the store to its bound `filePath`, entries sorted by key.
|
|
75
|
+
*
|
|
76
|
+
* @param registry - Store to write.
|
|
77
|
+
* @param handler - Serialization handler. Defaults to the store's handler, then `tsHandler`.
|
|
78
|
+
* @throws {Error} When the store has no bound `filePath`.
|
|
79
|
+
*/
|
|
80
|
+
export function flush(registry, handler) {
|
|
81
|
+
if (!registry.filePath) {
|
|
82
|
+
throw new Error("flush() requires a bound filePath. Use createRegistryStore({ filePath }) to bind one.");
|
|
83
|
+
}
|
|
84
|
+
const h = resolveHandler(registry, handler);
|
|
85
|
+
writeFileSync(registry.filePath, h.serialize(sortedEntries(registry)), "utf-8");
|
|
86
|
+
}
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
// writeTo (store → explicit path)
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
/**
|
|
91
|
+
* @brief Writes the store to an explicit path, entries sorted by key. The store's bound `filePath` is not changed.
|
|
92
|
+
*
|
|
93
|
+
* @param registry - Store to write.
|
|
94
|
+
* @param filePath - Absolute path to write to.
|
|
95
|
+
* @param handler - Serialization handler. Defaults to the store's handler, then `tsHandler`.
|
|
96
|
+
*/
|
|
97
|
+
export function writeTo(registry, filePath, handler) {
|
|
98
|
+
const h = resolveHandler(registry, handler);
|
|
99
|
+
writeFileSync(filePath, h.serialize(sortedEntries(registry)), "utf-8");
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=registry.io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.io.js","sourceRoot":"","sources":["../../src/registry/registry.io.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAIrD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAS,cAAc,CACrB,QAA0B,EAC1B,QAA6B;IAE7B,OAAO,QAAQ,IAAI,QAAQ,CAAC,OAAO,IAAI,SAAS,CAAA;AAClD,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAA8B,QAA0B;IAC5E,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,QAA0B,EAC1B,QAAgB;IAEhB,OAAO,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,QAA0B,EAC1B,QAAiB;IAEjB,MAAM,MAAM,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;IAC7C,IAAI,CAAC,MAAM;QAAE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AC,GAAG,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AACxE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BaseRegistryEntry } from "./types";
|
|
2
|
+
import type { RegistryStore } from "./registry.store";
|
|
3
|
+
/**
|
|
4
|
+
* @brief Registers an entry in the store, overwriting any entry under the same key.
|
|
5
|
+
*
|
|
6
|
+
* @param registry - Store to write to.
|
|
7
|
+
* @param key - Key the entry is stored under.
|
|
8
|
+
* @param entry - Entry to store.
|
|
9
|
+
*/
|
|
10
|
+
export declare function register<T extends BaseRegistryEntry>(registry: RegistryStore<T>, key: string, entry: T): void;
|
|
11
|
+
/**
|
|
12
|
+
* @brief Removes an entry from the store.
|
|
13
|
+
*
|
|
14
|
+
* @param registry - Store to remove from.
|
|
15
|
+
* @param key - Key of the entry to remove.
|
|
16
|
+
* @returns `true` if the entry existed, `false` if it was already absent.
|
|
17
|
+
*/
|
|
18
|
+
export declare function unregister<T extends BaseRegistryEntry>(registry: RegistryStore<T>, key: string): boolean;
|
|
19
|
+
//# sourceMappingURL=registry.mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.mutations.d.ts","sourceRoot":"","sources":["../../src/registry/registry.mutations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EAClD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,GACP,IAAI,CAEN;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,iBAAiB,EACpD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,GACV,OAAO,CAYT"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @brief Registers an entry in the store, overwriting any entry under the same key.
|
|
3
|
+
*
|
|
4
|
+
* @param registry - Store to write to.
|
|
5
|
+
* @param key - Key the entry is stored under.
|
|
6
|
+
* @param entry - Entry to store.
|
|
7
|
+
*/
|
|
8
|
+
export function register(registry, key, entry) {
|
|
9
|
+
registry.store.setState((s) => ({ ...s, [key]: entry }));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @brief Removes an entry from the store.
|
|
13
|
+
*
|
|
14
|
+
* @param registry - Store to remove from.
|
|
15
|
+
* @param key - Key of the entry to remove.
|
|
16
|
+
* @returns `true` if the entry existed, `false` if it was already absent.
|
|
17
|
+
*/
|
|
18
|
+
export function unregister(registry, key) {
|
|
19
|
+
const existed = key in registry.store.state;
|
|
20
|
+
if (existed) {
|
|
21
|
+
registry.store.setState((s) => {
|
|
22
|
+
const next = { ...s };
|
|
23
|
+
delete next[key];
|
|
24
|
+
return next;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return existed;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=registry.mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.mutations.js","sourceRoot":"","sources":["../../src/registry/registry.mutations.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CACtB,QAA0B,EAC1B,GAAW,EACX,KAAQ;IAER,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,QAA0B,EAC1B,GAAW;IAEX,MAAM,OAAO,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAA;IAE3C,IAAI,OAAO,EAAE,CAAC;QACZ,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;YACrB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;YAChB,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|