@g3nomaly/core 0.3.0 → 0.3.1
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 +17 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +76 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/installFromSources.d.ts +49 -0
- package/dist/cli/commands/installFromSources.d.ts.map +1 -0
- package/dist/cli/commands/installFromSources.js +138 -0
- package/dist/cli/commands/installFromSources.js.map +1 -0
- package/dist/cli/commands/ls.d.ts +16 -0
- package/dist/cli/commands/ls.d.ts.map +1 -0
- package/dist/cli/commands/ls.js +65 -0
- package/dist/cli/commands/ls.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +13 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +109 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/commands/sources.d.ts +45 -0
- package/dist/cli/commands/sources.d.ts.map +1 -0
- package/dist/cli/commands/sources.js +89 -0
- package/dist/cli/commands/sources.js.map +1 -0
- package/dist/cli/commands/update.d.ts +10 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +92 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/dialogue.d.ts +74 -0
- package/dist/cli/dialogue.d.ts.map +1 -0
- package/dist/cli/dialogue.js +117 -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 +15 -0
- package/dist/cli/installDialogues.d.ts.map +1 -0
- package/dist/cli/installDialogues.js +72 -0
- package/dist/cli/installDialogues.js.map +1 -0
- package/dist/cli/pick.d.ts +14 -0
- package/dist/cli/pick.d.ts.map +1 -0
- package/dist/cli/pick.js +35 -0
- package/dist/cli/pick.js.map +1 -0
- package/dist/cli/report.d.ts +34 -0
- package/dist/cli/report.d.ts.map +1 -0
- package/dist/cli/report.js +71 -0
- package/dist/cli/report.js.map +1 -0
- package/dist/cli/theme.d.ts +23 -0
- package/dist/cli/theme.d.ts.map +1 -0
- package/dist/cli/theme.js +25 -0
- package/dist/cli/theme.js.map +1 -0
- package/dist/cli/types.d.ts +45 -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 +30 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +77 -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 +124 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +61 -0
- package/dist/config/types.js.map +1 -0
- package/dist/hash/hash.d.ts +25 -0
- package/dist/hash/hash.d.ts.map +1 -0
- package/dist/hash/hash.js +44 -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 +2 -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 +2 -0
- package/dist/index.js.map +1 -0
- package/dist/installer/classify.d.ts +7 -0
- package/dist/installer/classify.d.ts.map +1 -0
- package/dist/installer/classify.js +47 -0
- package/dist/installer/classify.js.map +1 -0
- package/dist/installer/files.d.ts +15 -0
- package/dist/installer/files.d.ts.map +1 -0
- package/dist/installer/files.js +22 -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 +13 -0
- package/dist/installer/install.d.ts.map +1 -0
- package/dist/installer/install.js +61 -0
- package/dist/installer/install.js.map +1 -0
- package/dist/installer/io.d.ts +4 -0
- package/dist/installer/io.d.ts.map +1 -0
- package/dist/installer/io.js +18 -0
- package/dist/installer/io.js.map +1 -0
- package/dist/installer/manifest.d.ts +59 -0
- package/dist/installer/manifest.d.ts.map +1 -0
- package/dist/installer/manifest.js +60 -0
- package/dist/installer/manifest.js.map +1 -0
- package/dist/installer/manifestSources.d.ts +21 -0
- package/dist/installer/manifestSources.d.ts.map +1 -0
- package/dist/installer/manifestSources.js +39 -0
- package/dist/installer/manifestSources.js.map +1 -0
- package/dist/installer/marketplace.d.ts +34 -0
- package/dist/installer/marketplace.d.ts.map +1 -0
- package/dist/installer/marketplace.js +64 -0
- package/dist/installer/marketplace.js.map +1 -0
- package/dist/installer/origin.d.ts +43 -0
- package/dist/installer/origin.d.ts.map +1 -0
- package/dist/installer/origin.js +22 -0
- package/dist/installer/origin.js.map +1 -0
- package/dist/installer/remove.d.ts +14 -0
- package/dist/installer/remove.d.ts.map +1 -0
- package/dist/installer/remove.js +37 -0
- package/dist/installer/remove.js.map +1 -0
- package/dist/installer/resolve.d.ts +78 -0
- package/dist/installer/resolve.d.ts.map +1 -0
- package/dist/installer/resolve.js +184 -0
- package/dist/installer/resolve.js.map +1 -0
- package/dist/installer/sourceRegistry.d.ts +59 -0
- package/dist/installer/sourceRegistry.d.ts.map +1 -0
- package/dist/installer/sourceRegistry.js +71 -0
- package/dist/installer/sourceRegistry.js.map +1 -0
- package/dist/installer/types.d.ts +80 -0
- package/dist/installer/types.d.ts.map +1 -0
- package/dist/installer/types.js +21 -0
- package/dist/installer/types.js.map +1 -0
- package/dist/registry/index.d.ts +12 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +12 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/registry.handlers.d.ts +9 -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 +22 -0
- package/dist/registry/registry.io.d.ts.map +1 -0
- package/dist/registry/registry.io.js +78 -0
- package/dist/registry/registry.io.js.map +1 -0
- package/dist/registry/registry.mutations.d.ts +12 -0
- package/dist/registry/registry.mutations.d.ts.map +1 -0
- package/dist/registry/registry.mutations.js +22 -0
- package/dist/registry/registry.mutations.js.map +1 -0
- package/dist/registry/registry.selectors.d.ts +38 -0
- package/dist/registry/registry.selectors.d.ts.map +1 -0
- package/dist/registry/registry.selectors.js +61 -0
- package/dist/registry/registry.selectors.js.map +1 -0
- package/dist/registry/registry.store.d.ts +34 -0
- package/dist/registry/registry.store.d.ts.map +1 -0
- package/dist/registry/registry.store.js +27 -0
- package/dist/registry/registry.store.js.map +1 -0
- package/dist/registry/registry.template.d.ts +23 -0
- package/dist/registry/registry.template.d.ts.map +1 -0
- package/dist/registry/registry.template.js +63 -0
- package/dist/registry/registry.template.js.map +1 -0
- package/dist/registry/types.d.ts +33 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +25 -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 +2 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/securityParser.d.ts +14 -0
- package/dist/security/securityParser.d.ts.map +1 -0
- package/dist/security/securityParser.js +89 -0
- package/dist/security/securityParser.js.map +1 -0
- package/dist/security/securityWorker.d.ts +8 -0
- package/dist/security/securityWorker.d.ts.map +1 -0
- package/dist/security/securityWorker.js +158 -0
- package/dist/security/securityWorker.js.map +1 -0
- package/dist/sources/checkout.d.ts +14 -0
- package/dist/sources/checkout.d.ts.map +1 -0
- package/dist/sources/checkout.js +27 -0
- package/dist/sources/checkout.js.map +1 -0
- package/dist/sources/git.d.ts +9 -0
- package/dist/sources/git.d.ts.map +1 -0
- package/dist/sources/git.js +22 -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 +10 -0
- package/dist/sources/local.d.ts.map +1 -0
- package/dist/sources/local.js +20 -0
- package/dist/sources/local.js.map +1 -0
- package/dist/sources/npm.d.ts +13 -0
- package/dist/sources/npm.d.ts.map +1 -0
- package/dist/sources/npm.js +128 -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 +34 -0
- package/dist/sources/parse.d.ts.map +1 -0
- package/dist/sources/parse.js +92 -0
- package/dist/sources/parse.js.map +1 -0
- package/dist/sources/process.d.ts +18 -0
- package/dist/sources/process.d.ts.map +1 -0
- package/dist/sources/process.js +43 -0
- package/dist/sources/process.js.map +1 -0
- package/dist/sources/register.d.ts +16 -0
- package/dist/sources/register.d.ts.map +1 -0
- package/dist/sources/register.js +37 -0
- package/dist/sources/register.js.map +1 -0
- package/dist/sources/types.d.ts +73 -0
- package/dist/sources/types.d.ts.map +1 -0
- package/dist/sources/types.js +36 -0
- package/dist/sources/types.js.map +1 -0
- package/dist/utils/errors.d.ts +3 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +6 -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 +6 -0
- package/dist/utils/merge.d.ts.map +1 -0
- package/dist/utils/merge.js +21 -0
- package/dist/utils/merge.js.map +1 -0
- package/dist/utils/packageMeta.d.ts +12 -0
- package/dist/utils/packageMeta.d.ts.map +1 -0
- package/dist/utils/packageMeta.js +20 -0
- package/dist/utils/packageMeta.js.map +1 -0
- package/dist/utils/paths.d.ts +16 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +40 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/prompt.d.ts +3 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +8 -0
- package/dist/utils/prompt.js.map +1 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +103 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +64 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Copyright (c) 2026 G3NTs - G3nomaly
|
|
2
|
+
|
|
3
|
+
Elastic License 2.0
|
|
4
|
+
|
|
5
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
14
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
15
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
16
|
+
the limitations and conditions below.
|
|
17
|
+
|
|
18
|
+
## Limitations
|
|
19
|
+
|
|
20
|
+
You may not provide the software to third parties as a hosted or managed
|
|
21
|
+
service, where the service provides users with access to any substantial set of
|
|
22
|
+
the features or functionality of the software.
|
|
23
|
+
|
|
24
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
25
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
26
|
+
software that is protected by the license key.
|
|
27
|
+
|
|
28
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
29
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
30
|
+
to applicable law.
|
|
31
|
+
|
|
32
|
+
## Patents
|
|
33
|
+
|
|
34
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
35
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
36
|
+
sale, import and have imported the software, in each case subject to the
|
|
37
|
+
limitations and conditions in this license. This license does not cover any
|
|
38
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
39
|
+
the software. If you or your company make any written claim that the software
|
|
40
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
41
|
+
the software granted under these terms ends immediately. If your company makes
|
|
42
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
43
|
+
company.
|
|
44
|
+
|
|
45
|
+
## Notices
|
|
46
|
+
|
|
47
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
48
|
+
also gets a copy of these terms.
|
|
49
|
+
|
|
50
|
+
If you modify the software, you must include in any modified copies of the
|
|
51
|
+
software prominent notices stating that you have modified the software.
|
|
52
|
+
|
|
53
|
+
## No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
56
|
+
these terms.
|
|
57
|
+
|
|
58
|
+
## Termination
|
|
59
|
+
|
|
60
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
61
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
62
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
63
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
64
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
65
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
66
|
+
to terminate automatically and permanently.
|
|
67
|
+
|
|
68
|
+
## No Liability
|
|
69
|
+
|
|
70
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
71
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
72
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
73
|
+
legal claim.*
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
78
|
+
software the licensor makes available under these terms, including any portion
|
|
79
|
+
of it.
|
|
80
|
+
|
|
81
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
82
|
+
|
|
83
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
84
|
+
organization that you work for, plus all organizations that have control over,
|
|
85
|
+
are under the control of, or are under common control with that
|
|
86
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
87
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
88
|
+
otherwise. Control can be direct or indirect.
|
|
89
|
+
|
|
90
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
91
|
+
these terms.
|
|
92
|
+
|
|
93
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
94
|
+
|
|
95
|
+
**trademark** means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseFileEntry, BaseRegistry } from "../../registry/types";
|
|
2
|
+
import type { FileSource, InstallerIO } from "../../installer/types";
|
|
3
|
+
import type { AddDialogues, EntrySource, InstallOptions, InstallTarget } from "../types";
|
|
4
|
+
/** Hash of the package's current version of a file, derived from its content. */
|
|
5
|
+
export declare function latestHashFrom(source: FileSource, io: InstallerIO): (file: BaseFileEntry) => Promise<string>;
|
|
6
|
+
export declare function pickerChoices(registry: BaseRegistry): {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}[];
|
|
10
|
+
/**
|
|
11
|
+
* Installs entries into every target, keeping locally modified files. With no
|
|
12
|
+
* keys and an `onNoValue` dialogue the user picks from the registry. Local
|
|
13
|
+
* changes prompt keep/overwrite through `onCollision` unless `--force`.
|
|
14
|
+
* The caller resolves keys before and saves each target's store after.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addEntries(registry: BaseRegistry, targets: InstallTarget[], source: EntrySource, keys: string[], options?: InstallOptions, dialogues?: AddDialogues): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIxE,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIrE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzF,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,MAAM,CAAC,CAM5G;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAKxF;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,aAAa,EAAE,EACxB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,EAC5B,SAAS,GAAE,YAAiB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA4Cf"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// packages/core/src/cli/commands/add.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { get } from "../../registry/registry.selectors";
|
|
5
|
+
import { register } from "../../registry/registry.mutations";
|
|
6
|
+
import { applyClassifications, classifyFiles, recordedHashes } from "../../installer";
|
|
7
|
+
import { createInstallerIO } from "../../installer/io";
|
|
8
|
+
import { ConflictDecision, FileState } from "../../installer/types";
|
|
9
|
+
import { hashString } from "../../hash/hash";
|
|
10
|
+
import { guardCancel } from "../../utils/prompt";
|
|
11
|
+
import { runDialogueValue } from "../dialogue";
|
|
12
|
+
import { c, lineSuccess, lineWarn, lineInfo } from "../theme";
|
|
13
|
+
const KeysSchema = z.array(z.string());
|
|
14
|
+
/** Hash of the package's current version of a file, derived from its content. */
|
|
15
|
+
export function latestHashFrom(source, io) {
|
|
16
|
+
return async (file) => {
|
|
17
|
+
const content = await source(file);
|
|
18
|
+
if (content === null)
|
|
19
|
+
return "";
|
|
20
|
+
return content.kind === "copy" ? io.hashFile(content.sourcePath) : hashString(content.content);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function pickerChoices(registry) {
|
|
24
|
+
return Object.entries(registry).map(([key, meta]) => ({
|
|
25
|
+
value: key,
|
|
26
|
+
label: `${c.key(key)} ${chalk.dim("—")} ${chalk.dim(meta.description ?? meta.name)}`,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Installs entries into every target, keeping locally modified files. With no
|
|
31
|
+
* keys and an `onNoValue` dialogue the user picks from the registry. Local
|
|
32
|
+
* changes prompt keep/overwrite through `onCollision` unless `--force`.
|
|
33
|
+
* The caller resolves keys before and saves each target's store after.
|
|
34
|
+
*/
|
|
35
|
+
export async function addEntries(registry, targets, source, keys, options = {}, dialogues = {}) {
|
|
36
|
+
const io = createInstallerIO();
|
|
37
|
+
if (keys.length === 0 && dialogues.onNoValue !== undefined) {
|
|
38
|
+
const picked = guardCancel(await runDialogueValue(dialogues.onNoValue, { keyChoices: pickerChoices(registry) }, options.answers));
|
|
39
|
+
keys = KeysSchema.parse(picked ?? []);
|
|
40
|
+
}
|
|
41
|
+
for (const target of targets) {
|
|
42
|
+
if (targets.length > 1)
|
|
43
|
+
console.log(c.header(target.label));
|
|
44
|
+
for (const key of keys) {
|
|
45
|
+
const meta = registry[key];
|
|
46
|
+
if (!meta)
|
|
47
|
+
continue;
|
|
48
|
+
const fileSource = await source(meta);
|
|
49
|
+
const classifications = await classifyFiles(meta.files, target.installDir, recordedHashes(get(target.store, key)), io, latestHashFrom(fileSource, io));
|
|
50
|
+
let decision = ConflictDecision.Keep;
|
|
51
|
+
const hasLocalChanges = classifications.some((cl) => cl.state >= FileState.UserOnly);
|
|
52
|
+
if (hasLocalChanges && !options.force && dialogues.onCollision !== undefined) {
|
|
53
|
+
const answer = await runDialogueValue(dialogues.onCollision, { key: c.key(key), target: c.target(target.label) }, options.answers);
|
|
54
|
+
if (answer === ConflictDecision.Overwrite)
|
|
55
|
+
decision = ConflictDecision.Overwrite;
|
|
56
|
+
}
|
|
57
|
+
const result = await applyClassifications(classifications, fileSource, { decision, force: options.force ?? false }, io);
|
|
58
|
+
for (const file of result.missingSource) {
|
|
59
|
+
console.log(lineWarn(`No content for ${c.file(file)} in the package source — skipped`));
|
|
60
|
+
}
|
|
61
|
+
for (const file of result.kept) {
|
|
62
|
+
console.log(lineWarn(`${c.file(file)} has local changes — kept ${chalk.dim(`(use ${c.flag("-f")} to overwrite)`)}`));
|
|
63
|
+
}
|
|
64
|
+
if (result.written.length > 0) {
|
|
65
|
+
console.log(lineSuccess(`Installed ${c.key(key)} ${chalk.dim(`(${result.written.length} file${result.written.length === 1 ? "" : "s"})`)}`));
|
|
66
|
+
}
|
|
67
|
+
else if (result.kept.length === 0) {
|
|
68
|
+
console.log(lineInfo(`${c.key(key)} — already up to date`));
|
|
69
|
+
}
|
|
70
|
+
// Always record the on-disk state — its hashes are the baseline that
|
|
71
|
+
// lets later runs tell user edits from package changes.
|
|
72
|
+
register(target.store, key, { ...meta, files: result.files.map((f) => ({ ...f, version: meta.version })) });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/cli/commands/add.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC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KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;YACvH,CAAC;YACD,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,QAAQ,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/I,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,CAAC;YAC9D,CAAC;YAED,qEAAqE;YACrE,wDAAwD;YACxD,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9G,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { InstallManifest } from "../../installer/manifest";
|
|
3
|
+
import type { OriginEntry } from "../../installer/origin";
|
|
4
|
+
import type { SourceRegistry } from "../../installer/sourceRegistry";
|
|
5
|
+
import type { EntrySource, InstallOptions, InstallTarget } from "../types";
|
|
6
|
+
/** An install target together with the manifest that backs its store. */
|
|
7
|
+
export interface ManifestTarget extends InstallTarget {
|
|
8
|
+
manifest: InstallManifest;
|
|
9
|
+
}
|
|
10
|
+
/** What an installer tells the install commands about itself. */
|
|
11
|
+
export interface InstallCommandContext<T extends OriginEntry> {
|
|
12
|
+
/** Installer binary, for the hints it prints, e.g. `g3n-skills` */
|
|
13
|
+
bin: string;
|
|
14
|
+
/** What one entry is called, e.g. `skill` */
|
|
15
|
+
noun: string;
|
|
16
|
+
entrySchema: z.ZodType<T>;
|
|
17
|
+
/** Where entry files come from; copying out of each source's checkout (`entrySource`) when absent */
|
|
18
|
+
fileSource?: (registry: SourceRegistry<T>) => EntrySource;
|
|
19
|
+
}
|
|
20
|
+
/** Runs after a target's manifest is saved, with the keys just installed, updated or removed. */
|
|
21
|
+
export type AfterTarget = (target: ManifestTarget, keys: string[]) => void | Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Installs entries or whole groups from a source registry into every target,
|
|
24
|
+
* each with its dependencies from any source, and saves each manifest. With
|
|
25
|
+
* no names the user picks from what the sources offer.
|
|
26
|
+
*
|
|
27
|
+
* @param names - As typed: `<name>` or `<name>@<source>`, a name being an entry key or a group
|
|
28
|
+
*/
|
|
29
|
+
export declare function addFromSources<T extends OriginEntry>(targets: readonly ManifestTarget[], names: readonly string[], registry: SourceRegistry<T>, options: InstallOptions, context: InstallCommandContext<T>, after?: AfterTarget): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Re-installs installed entries from the source each one was installed
|
|
32
|
+
* from, at that source's current revision; with no names, everything
|
|
33
|
+
* installed. Names installed in no target are reported first, and the
|
|
34
|
+
* sources are only opened once something is left to update. Dependencies an
|
|
35
|
+
* entry gained since install are reported, not installed.
|
|
36
|
+
*
|
|
37
|
+
* @param openRegistry - Opens the source registry; the command disposes it
|
|
38
|
+
*/
|
|
39
|
+
export declare function updateFromSources<T extends OriginEntry>(targets: readonly ManifestTarget[], names: readonly string[], openRegistry: () => Promise<SourceRegistry<T>>, options: InstallOptions, context: InstallCommandContext<T>, after?: AfterTarget): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Removes installed entries, or whole groups, from every target and saves
|
|
42
|
+
* each manifest. Works from the manifests alone, so no source needs to be
|
|
43
|
+
* reachable; installed dependents are offered for removal too. With no names
|
|
44
|
+
* the user picks from what is installed.
|
|
45
|
+
*
|
|
46
|
+
* @param after - Gets the keys a target no longer holds, to clean up what the installer added beside the files
|
|
47
|
+
*/
|
|
48
|
+
export declare function removeFromTargets<T extends OriginEntry>(targets: readonly ManifestTarget[], names: readonly string[], options: InstallOptions, context: InstallCommandContext<T>, after?: AfterTarget): Promise<void>;
|
|
49
|
+
//# sourceMappingURL=installFromSources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installFromSources.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/installFromSources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAe,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAMlF,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAK3E,yEAAyE;AACzE,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED,iEAAiE;AACjE,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,WAAW;IAC1D,mEAAmE;IACnE,GAAG,EAAU,MAAM,CAAC;IACpB,6CAA6C;IAC7C,IAAI,EAAS,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,qGAAqG;IACrG,UAAU,CAAC,EAAE,CAAC,QAAQ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, resolveInstalled, resolveRequests, resolveUpdates } from "../../installer/resolve";
|
|
3
|
+
import { entrySource, offerRegistry, offers } from "../../installer/sourceRegistry";
|
|
4
|
+
import { runDialogueValue } from "../dialogue";
|
|
5
|
+
import { cascadeDialogue, incompleteDialogue, notInstalledDialogue, overwriteDialogue, removeChangedDialogue, selectRemovalDialogue } from "../installDialogues";
|
|
6
|
+
import { pickOffers } from "../pick";
|
|
7
|
+
import { reportResolution } from "../report";
|
|
8
|
+
import { c, lineError, lineInfo, lineWarn } from "../theme";
|
|
9
|
+
import { addEntries } from "./add";
|
|
10
|
+
import { removeEntries } from "./remove";
|
|
11
|
+
import { updateEntries } from "./update";
|
|
12
|
+
/** The context's file source for a registry, or a copy out of each source's checkout. */
|
|
13
|
+
function filesFrom(registry, context) {
|
|
14
|
+
return context.fileSource?.(registry) ?? entrySource(registry);
|
|
15
|
+
}
|
|
16
|
+
/** Installed entries of every target, each key once; the first target wins on a clash. */
|
|
17
|
+
function installedAcross(targets, schema) {
|
|
18
|
+
const installed = {};
|
|
19
|
+
for (const target of targets)
|
|
20
|
+
for (const [key, entry] of Object.entries(installedEntries(target.manifest, schema)))
|
|
21
|
+
installed[key] ??= entry;
|
|
22
|
+
return installed;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Installs entries or whole groups from a source registry into every target,
|
|
26
|
+
* each with its dependencies from any source, and saves each manifest. With
|
|
27
|
+
* no names the user picks from what the sources offer.
|
|
28
|
+
*
|
|
29
|
+
* @param names - As typed: `<name>` or `<name>@<source>`, a name being an entry key or a group
|
|
30
|
+
*/
|
|
31
|
+
export async function addFromSources(targets, names, registry, options, context, after) {
|
|
32
|
+
const available = offers(registry);
|
|
33
|
+
const requested = names.length > 0 ? [...names] : await pickOffers(available, context.noun, options.answers);
|
|
34
|
+
if (requested.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
const origins = installedOrigins(targets.map((t) => installedEntries(t.manifest, context.entrySchema)));
|
|
37
|
+
const resolution = resolveRequests(requested, available, origins);
|
|
38
|
+
await reportResolution(resolution, context, options.answers);
|
|
39
|
+
const selected = [...resolution.entries.values()];
|
|
40
|
+
const keys = selected.map((s) => s.key);
|
|
41
|
+
await addEntries(offerRegistry(selected), [...targets], filesFrom(registry, context), keys, options, { onCollision: overwriteDialogue });
|
|
42
|
+
for (const target of targets) {
|
|
43
|
+
saveInstallManifest(target.manifest, context.entrySchema);
|
|
44
|
+
await after?.(target, keys);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Warns about dependencies an entry now has that the target does not hold. */
|
|
48
|
+
function reportNewDependencies(updated, installed, context) {
|
|
49
|
+
for (const { key, entry } of updated) {
|
|
50
|
+
const missing = (entry.registryDependencies ?? []).filter((dep) => installed[dep] === undefined);
|
|
51
|
+
if (missing.length > 0) {
|
|
52
|
+
console.log(lineWarn(`${c.key(key)} now depends on ${missing.map((m) => c.key(m)).join(", ")}: run ${c.cmd(`${context.bin} add ${key}`)} to install them`));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Re-installs installed entries from the source each one was installed
|
|
58
|
+
* from, at that source's current revision; with no names, everything
|
|
59
|
+
* installed. Names installed in no target are reported first, and the
|
|
60
|
+
* sources are only opened once something is left to update. Dependencies an
|
|
61
|
+
* entry gained since install are reported, not installed.
|
|
62
|
+
*
|
|
63
|
+
* @param openRegistry - Opens the source registry; the command disposes it
|
|
64
|
+
*/
|
|
65
|
+
export async function updateFromSources(targets, names, openRegistry, options, context, after) {
|
|
66
|
+
const plans = targets.map((target) => {
|
|
67
|
+
const installed = installedEntries(target.manifest, context.entrySchema);
|
|
68
|
+
return { target, installed, ...(names.length > 0 ? resolveInstalled(names, installed) : { keys: Object.keys(installed), unknown: [] }) };
|
|
69
|
+
});
|
|
70
|
+
const unknown = [...new Set(plans.flatMap((p) => p.unknown))].filter((name) => plans.every((p) => p.unknown.includes(name)));
|
|
71
|
+
if (unknown.length > 0) {
|
|
72
|
+
const list = unknown.map((k) => c.key(k)).join(", ");
|
|
73
|
+
console.error(lineError(`Not installed: ${list}. Run ${c.cmd(`${context.bin} add`)} to install them.`));
|
|
74
|
+
const proceed = plans.some((p) => p.keys.length > 0)
|
|
75
|
+
&& (await runDialogueValue(notInstalledDialogue, { unknown: list }, options.answers)) === true;
|
|
76
|
+
if (!proceed)
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
if (plans.every((p) => p.keys.length === 0)) {
|
|
80
|
+
console.log(lineInfo("Nothing to update."));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const registry = await openRegistry();
|
|
84
|
+
const available = offers(registry);
|
|
85
|
+
const origins = installedOrigins(plans.map((p) => p.installed));
|
|
86
|
+
try {
|
|
87
|
+
for (const plan of plans) {
|
|
88
|
+
if (targets.length > 1)
|
|
89
|
+
console.log(c.header(plan.target.label));
|
|
90
|
+
if (plan.keys.length === 0) {
|
|
91
|
+
console.log(lineInfo("Nothing to update."));
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const { offers: updated, missing } = resolveUpdates(plan.keys, plan.installed, available, origins);
|
|
95
|
+
reportNewDependencies(updated, plan.installed, context);
|
|
96
|
+
for (const key of missing) {
|
|
97
|
+
console.log(lineWarn(`${c.key(key)}: its source ${c.key(plan.installed[key]?.origin.source ?? "")} is not registered or no longer offers it, left as is`));
|
|
98
|
+
}
|
|
99
|
+
if (updated.length === 0)
|
|
100
|
+
continue;
|
|
101
|
+
const keys = updated.map((u) => u.key);
|
|
102
|
+
await updateEntries(offerRegistry(updated), [plan.target], filesFrom(registry, context), keys, options, { onCollision: overwriteDialogue });
|
|
103
|
+
if (options.dryRun !== true) {
|
|
104
|
+
saveInstallManifest(plan.target.manifest, context.entrySchema);
|
|
105
|
+
await after?.(plan.target, keys);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
registry.dispose();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Removes installed entries, or whole groups, from every target and saves
|
|
115
|
+
* each manifest. Works from the manifests alone, so no source needs to be
|
|
116
|
+
* reachable; installed dependents are offered for removal too. With no names
|
|
117
|
+
* the user picks from what is installed.
|
|
118
|
+
*
|
|
119
|
+
* @param after - Gets the keys a target no longer holds, to clean up what the installer added beside the files
|
|
120
|
+
*/
|
|
121
|
+
export async function removeFromTargets(targets, names, options, context, after) {
|
|
122
|
+
const installed = installedAcross(targets, context.entrySchema);
|
|
123
|
+
// Unknown names stay in the list so the command reports them as "not installed".
|
|
124
|
+
const { keys, unknown } = resolveInstalled(names, installed);
|
|
125
|
+
const before = targets.map((t) => Object.keys(installedEntries(t.manifest, context.entrySchema)));
|
|
126
|
+
await removeEntries(installed, [...targets], [...keys, ...unknown], options, {
|
|
127
|
+
onNoValue: selectRemovalDialogue(context.noun),
|
|
128
|
+
onCascade: cascadeDialogue,
|
|
129
|
+
onCollision: removeChangedDialogue,
|
|
130
|
+
onIncomplete: incompleteDialogue,
|
|
131
|
+
});
|
|
132
|
+
for (const [index, target] of targets.entries()) {
|
|
133
|
+
saveInstallManifest(target.manifest, context.entrySchema);
|
|
134
|
+
const still = installedEntries(target.manifest, context.entrySchema);
|
|
135
|
+
await after?.(target, (before[index] ?? []).filter((key) => still[key] === undefined));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=installFromSources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installFromSources.js","sourceRoot":"","sources":["../../../src/cli/commands/installFromSources.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGjF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE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AO,CAAC,EAAE,OAAO,EAAE;QAC3E,SAAS,EAAK,qBAAqB,CAAC,OAAO,CAAC,IAAI,CAAC;QACjD,SAAS,EAAK,eAAe;QAC7B,WAAW,EAAG,qBAAqB;QACnC,YAAY,EAAE,kBAAkB;KACjC,CAAC,CAAC;IAEH,KAAK,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAChD,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QACrE,MAAM,KAAK,EAAE,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;IACzF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BaseRegistry } from "../../registry/types";
|
|
2
|
+
import type { LSOptions } from "../types";
|
|
3
|
+
import type { OriginEntry } from "../../installer/origin";
|
|
4
|
+
import type { SourceRegistry } from "../../installer/sourceRegistry";
|
|
5
|
+
import type { RegisteredSource } from "../../sources/types";
|
|
6
|
+
/** Lists the entries of a registry, grouped by each entry's `group`. */
|
|
7
|
+
export declare function lsEntries(registry: BaseRegistry, options?: LSOptions): void;
|
|
8
|
+
/**
|
|
9
|
+
* Lists what each source of a source registry offers: a header per source
|
|
10
|
+
* with where it comes from when `sources` holds its spec, then its entries by group, `●` marking the ones
|
|
11
|
+
* `installed` holds. With `json`, prints every offer as `{ key, ...entry }`.
|
|
12
|
+
*
|
|
13
|
+
* @param installed - Installed entries by key, to mark; empty to mark nothing
|
|
14
|
+
*/
|
|
15
|
+
export declare function lsSourceRegistry<T extends OriginEntry>(registry: SourceRegistry<T>, sources: readonly RegisteredSource[], installed: Record<string, OriginEntry>, options?: LSOptions): void;
|
|
16
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/ls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,GAAE,SAAc,GAAG,IAAI,CAiB/E;AASD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,WAAW,EACpD,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,EAC3B,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACtC,OAAO,GAAE,SAAc,GACtB,IAAI,CAwBN"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// packages/core/src/cli/commands/ls.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { c } from "../theme";
|
|
4
|
+
import { offers } from "../../installer/sourceRegistry";
|
|
5
|
+
import { describeSource } from "../../sources/checkout";
|
|
6
|
+
/** Lists the entries of a registry, grouped by each entry's `group`. */
|
|
7
|
+
export function lsEntries(registry, options = {}) {
|
|
8
|
+
if (options.json === true) {
|
|
9
|
+
console.log(JSON.stringify(registry, null, 2));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const byGroup = {};
|
|
13
|
+
for (const [key, meta] of Object.entries(registry))
|
|
14
|
+
(byGroup[meta.group ?? "default"] ??= []).push(key);
|
|
15
|
+
for (const group of Object.keys(byGroup).sort()) {
|
|
16
|
+
console.log(c.header(group));
|
|
17
|
+
for (const key of (byGroup[group] ?? []).sort()) {
|
|
18
|
+
const meta = registry[key];
|
|
19
|
+
console.log(` ${c.key(key.padEnd(26))} ${chalk.dim(meta?.description ?? "")}`);
|
|
20
|
+
}
|
|
21
|
+
console.log();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** ` at <commit>` or ` v<version>` of the checkout an entry was read from. */
|
|
25
|
+
function revision(origin) {
|
|
26
|
+
if (origin?.commit !== undefined)
|
|
27
|
+
return ` at ${origin.commit.slice(0, 7)}`;
|
|
28
|
+
if (origin?.version !== undefined)
|
|
29
|
+
return ` v${origin.version}`;
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Lists what each source of a source registry offers: a header per source
|
|
34
|
+
* with where it comes from when `sources` holds its spec, then its entries by group, `●` marking the ones
|
|
35
|
+
* `installed` holds. With `json`, prints every offer as `{ key, ...entry }`.
|
|
36
|
+
*
|
|
37
|
+
* @param installed - Installed entries by key, to mark; empty to mark nothing
|
|
38
|
+
*/
|
|
39
|
+
export function lsSourceRegistry(registry, sources, installed, options = {}) {
|
|
40
|
+
if (options.json === true) {
|
|
41
|
+
console.log(JSON.stringify(offers(registry).map(({ key, entry }) => ({ key, ...entry })), null, 2));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
for (const [name, store] of registry.sources) {
|
|
45
|
+
const listed = Object.entries(store.store.state).sort(([a], [b]) => a.localeCompare(b));
|
|
46
|
+
if (listed.length === 0)
|
|
47
|
+
continue;
|
|
48
|
+
const spec = sources.find((s) => s.name === name)?.spec;
|
|
49
|
+
const from = spec === undefined ? "" : describeSource(spec);
|
|
50
|
+
console.log(chalk.bold(`${name} ${chalk.dim(`${from}${revision(listed[0]?.[1].origin)}`)}`));
|
|
51
|
+
const byGroup = {};
|
|
52
|
+
for (const [key, entry] of listed)
|
|
53
|
+
(byGroup[entry.group ?? "default"] ??= []).push([key, entry]);
|
|
54
|
+
for (const group of Object.keys(byGroup).sort()) {
|
|
55
|
+
console.log(c.header(group));
|
|
56
|
+
for (const [key, entry] of byGroup[group] ?? []) {
|
|
57
|
+
const mark = installed[key]?.origin.source === name ? chalk.green("●") : " ";
|
|
58
|
+
const label = `${c.key(key)} ${chalk.dim(entry.version ?? "")}`;
|
|
59
|
+
console.log(` ${mark} ${label.padEnd(40)} ${chalk.dim(entry.description ?? "")}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
console.log();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../../src/cli/commands/ls.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,wEAAwE;AACxE,MAAM,UAAU,SAAS,CAAC,QAAsB,EAAE,OAAO,GAAc,EAAE;IACvE,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAA6B,EAAE,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,CAAC,OAAO,CAAC,IA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AAG,EAAE,KAAK,CAAC,CAAC,CAAC;QACjG,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAChD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;gBAChD,MAAM,IAAI,GAAI,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC9E,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,CAAC;gBAChE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BaseRegistry } from "../../registry/types";
|
|
2
|
+
import type { InstallOptions, InstallTarget, RemoveDialogues } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Removes installed entries and drops them from each target's store. With no
|
|
5
|
+
* keys and an `onNoValue` dialogue the user picks from what is installed.
|
|
6
|
+
* Removal is all-or-nothing per entry: local changes prompt keep/remove
|
|
7
|
+
* through `onCollision` (kept entirely without it), and an entry with files
|
|
8
|
+
* missing on disk proceeds only when `onIncomplete` confirms. Installed
|
|
9
|
+
* dependents (via `registryDependencies`) are offered for cascade removal
|
|
10
|
+
* through `onCascade`. The caller saves each target's store after.
|
|
11
|
+
*/
|
|
12
|
+
export declare function removeEntries(registry: BaseRegistry, targets: InstallTarget[], keys: string[], options?: InstallOptions, dialogues?: RemoveDialogues): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=remove.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/remove.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,sBAAsB,CAAC;AAO5E,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA0B/E;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,aAAa,EAAE,EACxB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,cAAmB,EAC5B,SAAS,GAAE,eAAoB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA4Ef"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// packages/core/src/cli/commands/remove.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { entries as storeEntries, entryDependencies, get } from "../../registry/registry.selectors";
|
|
6
|
+
import { unregister } from "../../registry/registry.mutations";
|
|
7
|
+
import { recordedHashes, removeInstalledFiles } from "../../installer";
|
|
8
|
+
import { createInstallerIO } from "../../installer/io";
|
|
9
|
+
import { ConflictDecision } from "../../installer/types";
|
|
10
|
+
import { guardCancel } from "../../utils/prompt";
|
|
11
|
+
import { runDialogueValue } from "../dialogue";
|
|
12
|
+
import { c, lineSuccess, lineWarn, lineInfo } from "../theme";
|
|
13
|
+
const KeysSchema = z.array(z.string());
|
|
14
|
+
async function diskState(entry, installDir, io) {
|
|
15
|
+
const recorded = recordedHashes(entry);
|
|
16
|
+
const missing = [];
|
|
17
|
+
const modified = [];
|
|
18
|
+
for (const file of entry.files) {
|
|
19
|
+
const destPath = path.join(installDir, file.path);
|
|
20
|
+
if (!io.exists(destPath)) {
|
|
21
|
+
missing.push(file.path);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const recordedHash = recorded[file.path];
|
|
25
|
+
if (recordedHash !== undefined && (await io.hashFile(destPath)) !== recordedHash)
|
|
26
|
+
modified.push(file.path);
|
|
27
|
+
}
|
|
28
|
+
return { missing, modified };
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Removes installed entries and drops them from each target's store. With no
|
|
32
|
+
* keys and an `onNoValue` dialogue the user picks from what is installed.
|
|
33
|
+
* Removal is all-or-nothing per entry: local changes prompt keep/remove
|
|
34
|
+
* through `onCollision` (kept entirely without it), and an entry with files
|
|
35
|
+
* missing on disk proceeds only when `onIncomplete` confirms. Installed
|
|
36
|
+
* dependents (via `registryDependencies`) are offered for cascade removal
|
|
37
|
+
* through `onCascade`. The caller saves each target's store after.
|
|
38
|
+
*/
|
|
39
|
+
export async function removeEntries(registry, targets, keys, options = {}, dialogues = {}) {
|
|
40
|
+
const io = createInstallerIO();
|
|
41
|
+
if (keys.length === 0 && dialogues.onNoValue !== undefined) {
|
|
42
|
+
const installed = [...new Set(targets.flatMap((t) => Object.keys(storeEntries(t.store))))].sort();
|
|
43
|
+
if (installed.length === 0) {
|
|
44
|
+
console.log(lineInfo("Nothing installed."));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const choices = installed.map((key) => ({ value: key, label: c.key(key) }));
|
|
48
|
+
const picked = guardCancel(await runDialogueValue(dialogues.onNoValue, { keyChoices: choices }, options.answers));
|
|
49
|
+
keys = KeysSchema.parse(picked ?? []);
|
|
50
|
+
}
|
|
51
|
+
for (const target of targets) {
|
|
52
|
+
if (targets.length > 1)
|
|
53
|
+
console.log(c.header(target.label));
|
|
54
|
+
const targetKeys = Object.keys(storeEntries(target.store));
|
|
55
|
+
// Mutable queue so cascade confirmations can append dependents mid-loop.
|
|
56
|
+
const queue = [...keys];
|
|
57
|
+
let i = 0;
|
|
58
|
+
while (i < queue.length) {
|
|
59
|
+
const key = queue[i++];
|
|
60
|
+
const installed = get(target.store, key);
|
|
61
|
+
if (!installed) {
|
|
62
|
+
console.log(lineInfo(`${c.key(key)} — not installed`));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const dependents = entryDependencies(key, registry, targetKeys).filter((d) => !queue.includes(d));
|
|
66
|
+
if (dependents.length > 0) {
|
|
67
|
+
console.log(lineWarn(`${dependents.map((d) => c.key(d)).join(", ")} depend${dependents.length === 1 ? "s" : ""} on ${c.key(key)}.`));
|
|
68
|
+
if (dialogues.onCascade !== undefined) {
|
|
69
|
+
const also = await runDialogueValue(dialogues.onCascade, { key: c.key(key), dependents: dependents.map((d) => c.key(d)).join(", ") }, options.answers);
|
|
70
|
+
if (also === true)
|
|
71
|
+
queue.push(...dependents);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const state = await diskState(installed, target.installDir, io);
|
|
75
|
+
if (state.missing.length > 0 && dialogues.onIncomplete !== undefined) {
|
|
76
|
+
console.log(lineWarn(`${c.key(key)} is incomplete on disk — missing ${state.missing.map((f) => c.file(f)).join(", ")}`));
|
|
77
|
+
const proceed = await runDialogueValue(dialogues.onIncomplete, { key: c.key(key), target: c.target(target.label), missing: state.missing.map((f) => c.file(f)).join(", ") }, options.answers);
|
|
78
|
+
if (proceed !== true) {
|
|
79
|
+
console.log(lineInfo(`${c.key(key)} — skipped`));
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let force = options.force ?? false;
|
|
84
|
+
if (state.modified.length > 0 && !force) {
|
|
85
|
+
console.log(lineWarn(`${c.key(key)} has local changes in ${state.modified.map((f) => c.file(f)).join(", ")}`));
|
|
86
|
+
if (dialogues.onCollision !== undefined) {
|
|
87
|
+
const answer = await runDialogueValue(dialogues.onCollision, { key: c.key(key), target: c.target(target.label) }, options.answers);
|
|
88
|
+
if (answer === ConflictDecision.Overwrite)
|
|
89
|
+
force = true;
|
|
90
|
+
}
|
|
91
|
+
if (!force) {
|
|
92
|
+
console.log(lineInfo(`${c.key(key)} — kept ${chalk.dim(`(use ${c.flag("-f")} to remove)`)}`));
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const result = await removeInstalledFiles(installed.files, target.installDir, { force }, io);
|
|
97
|
+
if (result.removed.length > 0) {
|
|
98
|
+
console.log(lineSuccess(`Removed ${c.key(key)} ${chalk.dim(`(${result.removed.length} file${result.removed.length === 1 ? "" : "s"})`)}`));
|
|
99
|
+
}
|
|
100
|
+
if (result.kept.length === 0) {
|
|
101
|
+
unregister(target.store, key);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
console.log(lineInfo(`${c.key(key)} kept in manifest (some files were kept)`));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=remove.js.map
|