@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
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,37 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* @brief Builds the hasher of a package's current version of each file.
|
|
6
|
+
*
|
|
7
|
+
* @param source - Source of each file's content in the package.
|
|
8
|
+
* @param io - Installer I/O that hashes copied files.
|
|
9
|
+
* @returns Function giving the hash of a file's package content, empty when the package has none.
|
|
10
|
+
*/
|
|
11
|
+
export declare function latestHashFrom(source: FileSource, io: InstallerIO): (file: BaseFileEntry) => Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* @brief Builds one picker choice per registry key, labelled with its description.
|
|
14
|
+
*
|
|
15
|
+
* @param registry - Registry whose keys are offered.
|
|
16
|
+
* @returns Choices with the key as value.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pickerChoices(registry: BaseRegistry): {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}[];
|
|
22
|
+
/**
|
|
23
|
+
* @brief Installs entries into every target, keeping locally modified files.
|
|
24
|
+
*
|
|
25
|
+
* With no keys and an `onNoValue` dialogue the user picks from the registry. Local
|
|
26
|
+
* changes prompt restore/fork/skip through `onCollision` unless `--force`.
|
|
27
|
+
* The caller resolves keys before and saves each target's store after.
|
|
28
|
+
*
|
|
29
|
+
* @param registry - Entries available to install, by key.
|
|
30
|
+
* @param targets - Destinations to install into.
|
|
31
|
+
* @param source - Source of each entry's files.
|
|
32
|
+
* @param keys - Keys to install; empty to pick from the registry.
|
|
33
|
+
* @param options - Force, dry run and preset answers.
|
|
34
|
+
* @param dialogues - Dialogues for the picker and for local changes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function addEntries(registry: BaseRegistry, targets: InstallTarget[], source: EntrySource, keys: string[], options?: InstallOptions, dialogues?: AddDialogues): Promise<void>;
|
|
37
|
+
//# 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;AAKrE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKzF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,MAAM,CAAC,CAM5G;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAKxF;AAED;;;;;;;;;;;;;GAaG;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,CA+Cf"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { chooseConflict, forkEntry } from "./conflict";
|
|
13
|
+
import { c, lineSuccess, lineWarn, lineInfo } from "../theme";
|
|
14
|
+
const KeysSchema = z.array(z.string());
|
|
15
|
+
/**
|
|
16
|
+
* @brief Builds the hasher of a package's current version of each file.
|
|
17
|
+
*
|
|
18
|
+
* @param source - Source of each file's content in the package.
|
|
19
|
+
* @param io - Installer I/O that hashes copied files.
|
|
20
|
+
* @returns Function giving the hash of a file's package content, empty when the package has none.
|
|
21
|
+
*/
|
|
22
|
+
export function latestHashFrom(source, io) {
|
|
23
|
+
return async (file) => {
|
|
24
|
+
const content = await source(file);
|
|
25
|
+
if (content === null)
|
|
26
|
+
return "";
|
|
27
|
+
return content.kind === "copy" ? io.hashFile(content.sourcePath) : hashString(content.content);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @brief Builds one picker choice per registry key, labelled with its description.
|
|
32
|
+
*
|
|
33
|
+
* @param registry - Registry whose keys are offered.
|
|
34
|
+
* @returns Choices with the key as value.
|
|
35
|
+
*/
|
|
36
|
+
export function pickerChoices(registry) {
|
|
37
|
+
return Object.entries(registry).map(([key, meta]) => ({
|
|
38
|
+
value: key,
|
|
39
|
+
label: `${c.key(key)} ${chalk.dim("—")} ${chalk.dim(meta.description ?? meta.name)}`,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* @brief Installs entries into every target, keeping locally modified files.
|
|
44
|
+
*
|
|
45
|
+
* With no keys and an `onNoValue` dialogue the user picks from the registry. Local
|
|
46
|
+
* changes prompt restore/fork/skip through `onCollision` unless `--force`.
|
|
47
|
+
* The caller resolves keys before and saves each target's store after.
|
|
48
|
+
*
|
|
49
|
+
* @param registry - Entries available to install, by key.
|
|
50
|
+
* @param targets - Destinations to install into.
|
|
51
|
+
* @param source - Source of each entry's files.
|
|
52
|
+
* @param keys - Keys to install; empty to pick from the registry.
|
|
53
|
+
* @param options - Force, dry run and preset answers.
|
|
54
|
+
* @param dialogues - Dialogues for the picker and for local changes.
|
|
55
|
+
*/
|
|
56
|
+
export async function addEntries(registry, targets, source, keys, options = {}, dialogues = {}) {
|
|
57
|
+
const io = createInstallerIO();
|
|
58
|
+
if (keys.length === 0 && dialogues.onNoValue !== undefined) {
|
|
59
|
+
const picked = guardCancel(await runDialogueValue(dialogues.onNoValue, { keyChoices: pickerChoices(registry) }, options.answers));
|
|
60
|
+
keys = KeysSchema.parse(picked ?? []);
|
|
61
|
+
}
|
|
62
|
+
for (const target of targets) {
|
|
63
|
+
if (targets.length > 1)
|
|
64
|
+
console.log(c.header(target.label));
|
|
65
|
+
for (const key of keys) {
|
|
66
|
+
const meta = registry[key];
|
|
67
|
+
if (!meta)
|
|
68
|
+
continue;
|
|
69
|
+
const installed = get(target.store, key);
|
|
70
|
+
const fileSource = await source(meta);
|
|
71
|
+
const classifications = await classifyFiles(meta.files, target.installDir, recordedHashes(installed), io, latestHashFrom(fileSource, io));
|
|
72
|
+
const hasLocalChanges = classifications.some((cl) => cl.state >= FileState.UserOnly);
|
|
73
|
+
const choice = hasLocalChanges
|
|
74
|
+
? await chooseConflict(dialogues.onCollision, key, installed ?? meta, target, options)
|
|
75
|
+
: { decision: ConflictDecision.Keep };
|
|
76
|
+
if (choice.decision === ConflictDecision.Fork) {
|
|
77
|
+
await forkEntry(target, key, installed ?? meta, choice.forkKey, io);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const result = await applyClassifications(classifications, fileSource, { decision: choice.decision, force: options.force ?? false }, io);
|
|
81
|
+
for (const file of result.missingSource) {
|
|
82
|
+
console.log(lineWarn(`No content for ${c.file(file)} in the package source — skipped`));
|
|
83
|
+
}
|
|
84
|
+
for (const file of result.kept) {
|
|
85
|
+
console.log(lineWarn(`${c.file(file)} has local changes — skipped ${chalk.dim(`(use ${c.flag("-f")} to overwrite)`)}`));
|
|
86
|
+
}
|
|
87
|
+
if (result.written.length > 0) {
|
|
88
|
+
console.log(lineSuccess(`Installed ${c.key(key)} ${chalk.dim(`(${result.written.length} file${result.written.length === 1 ? "" : "s"})`)}`));
|
|
89
|
+
}
|
|
90
|
+
else if (result.kept.length === 0) {
|
|
91
|
+
console.log(lineInfo(`${c.key(key)} — already up to date`));
|
|
92
|
+
}
|
|
93
|
+
// The recorded hashes are the baseline that lets later runs tell user
|
|
94
|
+
// edits from package changes; a skipped file keeps its install-time hash.
|
|
95
|
+
register(target.store, key, { ...meta, files: result.files.map((f) => ({ ...f, version: meta.version })) });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# 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,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Entry } from "../../registry/types";
|
|
2
|
+
import { ConflictDecision } from "../../installer/types";
|
|
3
|
+
import type { InstallerIO } from "../../installer/types";
|
|
4
|
+
import type { Dialogue } from "../dialogue";
|
|
5
|
+
import type { InstallInput, InstallOptions, InstallTarget } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* @brief What to do with one entry that has local changes.
|
|
8
|
+
*
|
|
9
|
+
* @property decision - Keep (skip), Overwrite (restore) or Fork.
|
|
10
|
+
* @property forkKey - Key the entry moves to, on a fork only.
|
|
11
|
+
*/
|
|
12
|
+
export type ConflictChoice = {
|
|
13
|
+
decision: typeof ConflictDecision.Keep | typeof ConflictDecision.Overwrite;
|
|
14
|
+
} | {
|
|
15
|
+
decision: typeof ConflictDecision.Fork;
|
|
16
|
+
forkKey: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @brief Returns the key an installed entry was forked from.
|
|
20
|
+
*
|
|
21
|
+
* @param entry - Installed entry to check.
|
|
22
|
+
* @returns The original key, or `undefined` when the entry is no fork.
|
|
23
|
+
*/
|
|
24
|
+
export declare function forkedFrom(entry: BaseRegistryEntry): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* @brief Asks what to do with `key`, whose files in `target` have local changes: restore, fork or skip.
|
|
27
|
+
*
|
|
28
|
+
* `--force` restores without asking. No dialogue, a cancelled one, or a fork onto a key the target
|
|
29
|
+
* already holds skips.
|
|
30
|
+
*
|
|
31
|
+
* @param dialogue - Asks for the decision; `undefined` skips.
|
|
32
|
+
* @param key - Key of the entry with local changes.
|
|
33
|
+
* @param entry - The entry as installed, or as offered; its `name` seeds the suggested fork key.
|
|
34
|
+
* @param target - Install target the entry is in.
|
|
35
|
+
* @param options - Force flag and preset answers.
|
|
36
|
+
* @returns The decision, with the key a fork moves to.
|
|
37
|
+
*/
|
|
38
|
+
export declare function chooseConflict(dialogue: Dialogue<InstallInput> | undefined, key: string, entry: BaseRegistryEntry, target: InstallTarget, options: InstallOptions): Promise<ConflictChoice>;
|
|
39
|
+
/**
|
|
40
|
+
* @brief Moves `key` in `target` to the local entry `forkKey`: the files `base` lists that are on disk, each
|
|
41
|
+
* with its current hash, and `forkedFrom` naming `key`. Writes no file, so imports of the files keep
|
|
42
|
+
* working.
|
|
43
|
+
*
|
|
44
|
+
* @param target - Install target holding the entry.
|
|
45
|
+
* @param key - Key of the entry being forked.
|
|
46
|
+
* @param base - The entry as installed, or as offered when the target never recorded it
|
|
47
|
+
* @param forkKey - Key the local entry takes.
|
|
48
|
+
* @param io - Installer I/O that hashes the files on disk.
|
|
49
|
+
* @throws {Error} When none of the entry's files is on disk
|
|
50
|
+
*/
|
|
51
|
+
export declare function forkEntry(target: InstallTarget, key: string, base: BaseRegistryEntry, forkKey: string, io: InstallerIO): Promise<void>;
|
|
52
|
+
//# sourceMappingURL=conflict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/conflict.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAiB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG5E;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,EAAE,OAAO,gBAAgB,CAAC,IAAI,GAAG,OAAO,gBAAgB,CAAC,SAAS,CAAA;CAAE,GAC9E;IAAE,QAAQ,EAAE,OAAO,gBAAgB,CAAC,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAMhE;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAGvE;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,SAAS,EAC5C,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5I"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// packages/core/src/cli/commands/conflict.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { get } from "../../registry/registry.selectors";
|
|
6
|
+
import { register, unregister } from "../../registry/registry.mutations";
|
|
7
|
+
import { ConflictDecision } from "../../installer/types";
|
|
8
|
+
import { runDialogue } from "../dialogue";
|
|
9
|
+
import { c, lineSuccess, lineWarn } from "../theme";
|
|
10
|
+
const SKIP = { decision: ConflictDecision.Keep };
|
|
11
|
+
const ForkSchema = z.object({ forkedFrom: z.string().min(1) });
|
|
12
|
+
/**
|
|
13
|
+
* @brief Returns the key an installed entry was forked from.
|
|
14
|
+
*
|
|
15
|
+
* @param entry - Installed entry to check.
|
|
16
|
+
* @returns The original key, or `undefined` when the entry is no fork.
|
|
17
|
+
*/
|
|
18
|
+
export function forkedFrom(entry) {
|
|
19
|
+
const fork = ForkSchema.safeParse(entry);
|
|
20
|
+
return fork.success ? fork.data.forkedFrom : undefined;
|
|
21
|
+
}
|
|
22
|
+
const ConflictAnswersSchema = z.object({
|
|
23
|
+
conflict: z.union([z.literal(ConflictDecision.Keep), z.literal(ConflictDecision.Overwrite), z.literal(ConflictDecision.Fork)]),
|
|
24
|
+
forkName: z.string().trim().min(1).optional(),
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* @brief Asks what to do with `key`, whose files in `target` have local changes: restore, fork or skip.
|
|
28
|
+
*
|
|
29
|
+
* `--force` restores without asking. No dialogue, a cancelled one, or a fork onto a key the target
|
|
30
|
+
* already holds skips.
|
|
31
|
+
*
|
|
32
|
+
* @param dialogue - Asks for the decision; `undefined` skips.
|
|
33
|
+
* @param key - Key of the entry with local changes.
|
|
34
|
+
* @param entry - The entry as installed, or as offered; its `name` seeds the suggested fork key.
|
|
35
|
+
* @param target - Install target the entry is in.
|
|
36
|
+
* @param options - Force flag and preset answers.
|
|
37
|
+
* @returns The decision, with the key a fork moves to.
|
|
38
|
+
*/
|
|
39
|
+
export async function chooseConflict(dialogue, key, entry, target, options) {
|
|
40
|
+
if (options.force === true)
|
|
41
|
+
return { decision: ConflictDecision.Overwrite };
|
|
42
|
+
if (dialogue === undefined)
|
|
43
|
+
return SKIP;
|
|
44
|
+
const input = { key: c.key(key), target: c.target(target.label), forkName: `${entry.name}-local` };
|
|
45
|
+
const record = await runDialogue(dialogue, input, options.answers);
|
|
46
|
+
if (typeof record === "symbol")
|
|
47
|
+
return SKIP;
|
|
48
|
+
const answers = ConflictAnswersSchema.safeParse(record);
|
|
49
|
+
if (!answers.success)
|
|
50
|
+
return SKIP;
|
|
51
|
+
const { conflict, forkName } = answers.data;
|
|
52
|
+
if (conflict !== ConflictDecision.Fork)
|
|
53
|
+
return { decision: conflict };
|
|
54
|
+
if (forkName === undefined)
|
|
55
|
+
return SKIP;
|
|
56
|
+
if (get(target.store, forkName) !== undefined) {
|
|
57
|
+
console.log(lineWarn(`${c.key(forkName)} is already installed — ${c.key(key)} skipped, nothing forked`));
|
|
58
|
+
return SKIP;
|
|
59
|
+
}
|
|
60
|
+
return { decision: ConflictDecision.Fork, forkKey: forkName };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @brief Moves `key` in `target` to the local entry `forkKey`: the files `base` lists that are on disk, each
|
|
64
|
+
* with its current hash, and `forkedFrom` naming `key`. Writes no file, so imports of the files keep
|
|
65
|
+
* working.
|
|
66
|
+
*
|
|
67
|
+
* @param target - Install target holding the entry.
|
|
68
|
+
* @param key - Key of the entry being forked.
|
|
69
|
+
* @param base - The entry as installed, or as offered when the target never recorded it
|
|
70
|
+
* @param forkKey - Key the local entry takes.
|
|
71
|
+
* @param io - Installer I/O that hashes the files on disk.
|
|
72
|
+
* @throws {Error} When none of the entry's files is on disk
|
|
73
|
+
*/
|
|
74
|
+
export async function forkEntry(target, key, base, forkKey, io) {
|
|
75
|
+
const files = [];
|
|
76
|
+
for (const file of base.files) {
|
|
77
|
+
const destPath = path.join(target.installDir, file.path);
|
|
78
|
+
if (io.exists(destPath))
|
|
79
|
+
files.push({ ...file, hash: await io.hashFile(destPath) });
|
|
80
|
+
}
|
|
81
|
+
if (files.length === 0)
|
|
82
|
+
throw new Error(`cannot fork ${key}: none of its files is on disk`);
|
|
83
|
+
const fork = { ...base, forkedFrom: key, files };
|
|
84
|
+
unregister(target.store, key);
|
|
85
|
+
register(target.store, forkKey, fork);
|
|
86
|
+
console.log(lineSuccess(`Forked ${c.key(key)} as ${c.key(forkKey)} ${chalk.dim("— updates leave it alone")}`));
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=conflict.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict.js","sourceRoot":"","sources":["../../../src/cli/commands/conflict.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,UAAU,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;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAqB,EAAE,GAAW,EAAE,IAAuB,EAAE,OAAe,EAAE,EAAe;IAC3H,MAAM,KAAK,GAAoB,EAAE,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,gCAAgC,CAAC,CAAC;IAE5F,MAAM,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IACjD,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* @brief An install target together with the manifest that backs its store.
|
|
8
|
+
*
|
|
9
|
+
* @property manifest - Manifest the store is saved to.
|
|
10
|
+
*/
|
|
11
|
+
export interface ManifestTarget extends InstallTarget {
|
|
12
|
+
manifest: InstallManifest;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @brief What an installer tells the install commands about itself.
|
|
16
|
+
*
|
|
17
|
+
* @property bin - Installer binary, for the hints it prints, e.g. `g3n-skills`.
|
|
18
|
+
* @property noun - What one entry is called, e.g. `skill`.
|
|
19
|
+
* @property entrySchema - Schema installed entries are parsed with.
|
|
20
|
+
* @property fileSource - Where entry files come from; copying out of each source's checkout (`entrySource`) when absent.
|
|
21
|
+
*/
|
|
22
|
+
export interface InstallCommandContext<T extends OriginEntry> {
|
|
23
|
+
bin: string;
|
|
24
|
+
noun: string;
|
|
25
|
+
entrySchema: z.ZodType<T>;
|
|
26
|
+
fileSource?: (registry: SourceRegistry<T>) => EntrySource;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @brief Runs after a target's manifest is saved, with the keys just installed, updated or removed.
|
|
30
|
+
*
|
|
31
|
+
* @param target - Target whose manifest was saved.
|
|
32
|
+
* @param keys - Keys just installed, updated or removed.
|
|
33
|
+
*/
|
|
34
|
+
export type AfterTarget = (target: ManifestTarget, keys: string[]) => void | Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* @brief Installs entries or whole groups from a source registry into every target,
|
|
37
|
+
* each with its dependencies from any source, and saves each manifest. With
|
|
38
|
+
* no names the user picks from what the sources offer. A key an installed
|
|
39
|
+
* fork stands in for is not installed.
|
|
40
|
+
*
|
|
41
|
+
* @param names - As typed: `<name>` or `<name>@<source>`, a name being an entry key or a group
|
|
42
|
+
* @param targets - Install targets, each with its manifest.
|
|
43
|
+
* @param registry - Source registry the names are resolved against.
|
|
44
|
+
* @param options - Force, dry run and preset answers.
|
|
45
|
+
* @param context - What the installer calls itself.
|
|
46
|
+
* @param after - Runs after each manifest is saved.
|
|
47
|
+
*/
|
|
48
|
+
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>;
|
|
49
|
+
/**
|
|
50
|
+
* @brief Re-installs installed entries from the source each one was installed
|
|
51
|
+
* from, at that source's current revision; with no names, everything
|
|
52
|
+
* installed. Forks are reported and left alone. Names installed in no
|
|
53
|
+
* target are reported first, and the sources are only opened once something
|
|
54
|
+
* is left to update. Dependencies an entry gained since install are
|
|
55
|
+
* reported, not installed.
|
|
56
|
+
*
|
|
57
|
+
* @param targets - Install targets, each with its manifest.
|
|
58
|
+
* @param names - Names to update; empty to update everything installed.
|
|
59
|
+
* @param openRegistry - Opens the source registry; the command disposes it
|
|
60
|
+
* @param options - Force, dry run and preset answers.
|
|
61
|
+
* @param context - What the installer calls itself.
|
|
62
|
+
* @param after - Runs after each manifest is saved.
|
|
63
|
+
*/
|
|
64
|
+
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>;
|
|
65
|
+
/**
|
|
66
|
+
* @brief Removes installed entries, or whole groups, from every target and saves
|
|
67
|
+
* each manifest. Works from the manifests alone, so no source needs to be
|
|
68
|
+
* reachable; installed dependents are offered for removal too. With no names
|
|
69
|
+
* the user picks from what is installed.
|
|
70
|
+
*
|
|
71
|
+
* @param after - Gets the keys a target no longer holds, to clean up what the installer added beside the files
|
|
72
|
+
* @param targets - Install targets, each with its manifest.
|
|
73
|
+
* @param names - Names to remove; empty to pick from what is installed.
|
|
74
|
+
* @param options - Force flag and preset answers.
|
|
75
|
+
* @param context - What the installer calls itself.
|
|
76
|
+
*/
|
|
77
|
+
export declare function removeFromTargets<T extends OriginEntry>(targets: readonly ManifestTarget[], names: readonly string[], options: InstallOptions, context: InstallCommandContext<T>, after?: AfterTarget): Promise<void>;
|
|
78
|
+
//# 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;;;;GAIG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,SAAS,WAAW;IAC1D,GAAG,EAAU,MAAM,CAAC;IACpB,IAAI,EAAS,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC;CAC3D;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AA0B3F;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,WAAW,EACxD,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,cAAc,CAA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