-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
index.ts
214 lines (203 loc) Β· 8.68 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
import {Descriptor, Plugin, SettingsType, Package, formatUtils} from '@yarnpkg/core';
import {Workspace} from '@yarnpkg/core';
import {isCI} from 'ci-info';
import AddCommand from './commands/add';
import BinCommand from './commands/bin';
import CacheCleanCommand from './commands/cache/clean';
import ConfigGetCommand from './commands/config/get';
import ConfigSetCommand from './commands/config/set';
import ConfigUnsetCommand from './commands/config/unset';
import ConfigCommand from './commands/config';
import DedupeCommand from './commands/dedupe';
import ClipanionCommand from './commands/entries/clipanion';
import HelpCommand from './commands/entries/help';
import EntryCommand from './commands/entries/run';
import VersionCommand from './commands/entries/version';
import ExecCommand from './commands/exec';
import ExplainPeerRequirementsCommand from './commands/explain/peerRequirements';
import ExplainCommand from './commands/explain';
import InfoCommand from './commands/info';
import YarnCommand from './commands/install';
import LinkCommand from './commands/link';
import NodeCommand from './commands/node';
import PluginCheckCommand from './commands/plugin/check';
import PluginImportSourcesCommand from './commands/plugin/import/sources';
import PluginImportCommand from './commands/plugin/import';
import PluginListCommand from './commands/plugin/list';
import PluginRemoveCommand from './commands/plugin/remove';
import PluginRuntimeCommand from './commands/plugin/runtime';
import RebuildCommand from './commands/rebuild';
import RemoveCommand from './commands/remove';
import RunIndexCommand from './commands/runIndex';
import RunCommand from './commands/run';
import SetResolutionCommand from './commands/set/resolution';
import SetVersionSourcesCommand from './commands/set/version/sources';
import SetVersionCommand from './commands/set/version';
import UnlinkCommand from './commands/unlink';
import UpCommand from './commands/up';
import WhyCommand from './commands/why';
import WorkspacesListCommand from './commands/workspaces/list';
import WorkspaceCommand from './commands/workspace';
import * as dedupeUtils from './dedupeUtils';
import * as suggestUtils from './suggestUtils';
export {AddCommand};
export {BinCommand};
export {CacheCleanCommand};
export {ConfigGetCommand};
export {ConfigSetCommand};
export {ConfigUnsetCommand};
export {ConfigCommand};
export {DedupeCommand};
export {ClipanionCommand};
export {HelpCommand};
export {EntryCommand};
export {VersionCommand};
export {ExecCommand};
export {ExplainPeerRequirementsCommand};
export {ExplainCommand};
export {InfoCommand};
export {YarnCommand};
export {LinkCommand};
export {NodeCommand};
export {PluginImportSourcesCommand};
export {PluginCheckCommand};
export {PluginImportCommand};
export {PluginListCommand};
export {PluginRemoveCommand};
export {PluginRuntimeCommand};
export {RebuildCommand};
export {RemoveCommand};
export {RunIndexCommand};
export {RunCommand};
export {SetResolutionCommand};
export {SetVersionSourcesCommand};
export {SetVersionCommand};
export {UnlinkCommand};
export {UpCommand};
export {WhyCommand};
export {WorkspacesListCommand};
export {WorkspaceCommand};
export {dedupeUtils};
export {suggestUtils};
export interface Hooks {
/**
* Called when a new dependency is added to a workspace. Note that this hook
* is only called by the CLI commands like `yarn add` - manually adding the
* dependencies into the manifest and running `yarn install` won't trigger
* it.
*/
afterWorkspaceDependencyAddition?: (
workspace: Workspace,
target: suggestUtils.Target,
descriptor: Descriptor,
strategies: Array<suggestUtils.Strategy>
) => Promise<void>;
/**
* Called when a dependency range is replaced inside a workspace. Note that
* this hook is only called by the CLI commands like `yarn add` - manually
* updating the dependencies from the manifest and running `yarn install`
* won't trigger it.
*/
afterWorkspaceDependencyReplacement?: (
workspace: Workspace,
target: suggestUtils.Target,
fromDescriptor: Descriptor,
toDescriptor: Descriptor,
) => Promise<void>;
/**
* Called when a dependency range is removed from a workspace. Note that
* this hook is only called by the CLI commands like `yarn remove` - manually
* removing the dependencies from the manifest and running `yarn install`
* won't trigger it.
*/
afterWorkspaceDependencyRemoval?: (
workspace: Workspace,
target: suggestUtils.Target,
descriptor: Descriptor,
) => Promise<void>;
/**
* Called by `yarn info`. The `extra` field is the set of parameters passed
* to the `-X,--extra` flag. Calling `registerData` will add a new set of
* data that will be added to the package information.
*
* For instance, an "audit" plugin could check in `extra` whether the user
* requested audit information (via `-X audit`), and call `registerData`
* with those information (retrieved dynamically) if they did.
*/
fetchPackageInfo?: (
pkg: Package,
extra: Set<string>,
registerData: (namespace: string, data: Array<formatUtils.Tuple> | {[key: string]: formatUtils.Tuple | undefined}) => void,
) => Promise<void>;
}
declare module '@yarnpkg/core' {
interface ConfigurationValueMap {
enableImmutableInstalls: boolean;
// Can't use Modifier here because there are actually two instances of this module:
// One in packages/plugin-essentials and one virtual package.
// Defining this property with two different enum instances leads to a compiler error.
defaultSemverRangePrefix: `^` | `~` | ``;
preferReuse: boolean;
}
}
const plugin: Plugin = {
configuration: {
enableImmutableInstalls: {
description: `If true (the default on CI), prevents the install command from modifying the lockfile`,
type: SettingsType.BOOLEAN,
default: isCI,
},
defaultSemverRangePrefix: {
description: `The default save prefix: '^', '~' or ''`,
type: SettingsType.STRING,
values: [`^`, `~`, ``],
default: suggestUtils.Modifier.CARET,
},
preferReuse: {
description: `If true, \`yarn add\` will attempt to reuse the most common dependency range in other workspaces.`,
type: SettingsType.BOOLEAN,
default: false,
},
},
commands: [
CacheCleanCommand,
ConfigGetCommand,
ConfigSetCommand,
ConfigUnsetCommand,
SetResolutionCommand,
SetVersionSourcesCommand,
SetVersionCommand,
WorkspacesListCommand,
ClipanionCommand,
HelpCommand,
EntryCommand,
VersionCommand,
AddCommand,
BinCommand,
ConfigCommand,
DedupeCommand,
ExecCommand,
ExplainPeerRequirementsCommand,
ExplainCommand,
InfoCommand,
YarnCommand,
LinkCommand,
UnlinkCommand,
NodeCommand,
PluginCheckCommand,
PluginImportSourcesCommand,
PluginImportCommand,
PluginRemoveCommand,
PluginListCommand,
PluginRuntimeCommand,
RebuildCommand,
RemoveCommand,
RunIndexCommand,
RunCommand,
UpCommand,
WhyCommand,
WorkspaceCommand,
],
};
// eslint-disable-next-line arca/no-default-export
export default plugin;