Repository navigation
Expand file tree
/
Copy pathmessages.js
More file actions
423 lines (355 loc) · 11.7 KB
/
Copy pathmessages.js
File metadata and controls
423 lines (355 loc) · 11.7 KB
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
// @flow
import chalk from 'chalk';
import Package from '../Package';
/*::
export opaque type Message = string;
*/
export function toString(message: Message | Buffer | string): string {
return message.toString();
}
export function toMessage(str: string): Message {
return str;
}
function normalPkg(str: string) {
return chalk.cyan(`"${str}"`);
}
function goodVer(str) {
return chalk.green(`"${str}"`);
}
function badVer(str) {
return chalk.red(`"${str}"`);
}
function cmd(str) {
return chalk.bgBlack.magenta(`\`${str}\``);
}
const importantSeparator = chalk.red(
'===============================IMPORTANT!==============================='
);
export function packageMustDependOnCurrentVersion(
name: string,
depName: string,
expected: string,
actual: string
): Message {
return `Package ${normalPkg(
name
)} must depend on the current version of ${normalPkg(depName)}: ${goodVer(
expected
)} vs ${badVer(actual)}`;
}
export function depMustBeAddedToProject(
pkgName: string,
depName: string
): Message {
return `Package ${normalPkg(pkgName)} dependency ${normalPkg(
depName
)} must be added to project dependencies.`;
}
export function depMustMatchProject(
pkgName: string,
depName: string,
expected: string,
actual: string
): Message {
return `Package ${normalPkg(pkgName)} dependency ${normalPkg(
depName
)} must match version in project dependencies. ${goodVer(
expected
)} vs ${badVer(actual)}`;
}
export function projectCannotDependOnWorkspace(depName: string): Message {
return `Project cannot depend on workspace Package ${normalPkg(depName)}`;
}
export function invalidBoltVersion(
actualVersion: string,
expectedVersion: string
): Message {
return `Project expects a bolt version of ${goodVer(
expectedVersion
)} but found ${badVer(actualVersion)}
run \`yarn global add "bolt@${expectedVersion}"\` to resolve`;
}
export function unableToUpdateDepVersion(
pkgName: string,
depName: string,
version: string
): Message {
return `Unable to update package ${normalPkg(pkgName)} dependency ${normalPkg(
depName
)} to version ${goodVer(version)}`;
}
export function addedPackageDependency(
pkgName: string,
depName: string,
versionRange: string
): Message {
return `Added package ${normalPkg(pkgName)} dependency ${normalPkg(
depName
)} at version ${goodVer(versionRange)}`;
}
export function updatedPackageDependency(
pkgName: string,
depName: string,
versionRange: string,
prevVersionRange: string
): Message {
return `Updated package ${normalPkg(pkgName)} dependency ${normalPkg(
depName
)} to version ${goodVer(versionRange)} from ${badVer(prevVersionRange)}`;
}
export function removedPackageDependency(
pkgName: string,
depName: string
): Message {
return `Removed package ${normalPkg(pkgName)} dependency ${normalPkg(
depName
)}`;
}
export function unableToNormalizeVersionRanges(
depName: string,
versionDetails: string
): Message {
return `Unable to normalize ${normalPkg(
depName
)} for version ranges: ${versionDetails}`;
}
export function dependencyNotInstalled(depName: string): Message {
return `You do not have a dependency named ${normalPkg(depName)} installed.`;
}
export function cannotRemoveDependencyDependendOnByWorkspaces(
depName: string,
packages: Array<Package>
): Message {
return `Cannot remove dependency ${normalPkg(
depName
)} that is depended on by some workspaces:\n${packages
.map(pkg => ` - ${normalPkg(pkg.getName())}`)
.join('\n')}`;
}
export function externalDepsPassedToUpdatePackageVersions(
externalDeps: Array<string>
): Message {
return `Attempted to pass external dependencies to updatePackageVersions:\n${externalDeps.join(
', '
)}`;
}
export function runWorkspacesRemoveDependency(depName: string): Message {
return `Run ${cmd(
`bolt workspaces remove ${depName}`
)} to remove from all workspaces`;
}
export function couldntRemoveDependencies(deps: Array<string>): Message {
return `Could not remove dependencies:\n${deps
.map(depName => ` - ${normalPkg(depName)}`)
.join('\n')}`;
}
export function couldntSymlinkDependencyNotExists(
pkgName: string,
depName: string
): Message {
return `Could not symlink ${depName} in ${pkgName} as no dependency exists`;
}
export function doneInSeconds(rounded: number): Message {
return `Done in ${rounded}s.`;
}
export function boltVersion(version: string): Message {
return `bolt v${version}`;
}
export function nodeVersion(version: string): Message {
return `(node v${version})`;
}
export function helpContent(): string {
return `
usage
$ bolt [command] <...args> <...opts>
options:
--no-prefix Do not prefix spawned process output with the command string
commands
init init a bolt project
install install a bolt project
add add a dependency to a bolt project
upgrade upgrade a dependency in a bolt project
remove remove a dependency from a bolt project
exec execute a command in a bolt project
run run a script in a bolt project
publish publish all the packages in a bolt project
workspaces run a bolt command inside all workspaces
workspace run a bolt command inside a specific workspace
help get help with bolt commands
`;
}
export function noPackagesMatchFilters(): Message {
return 'No packages match the filters provided';
}
export function removedDependencies(): Message {
return 'Removed dependencies';
}
export function npmPackageCouldNotBeFound(pkgName: string): Message {
return `Package named ${normalPkg(
pkgName
)} could not be found, this could mean you have not published this package yet`;
}
export function notDistTagFound(tagName: string, pkgName: string): Message {
return `No dist tag ${normalPkg(tagName)} found for package ${normalPkg(
pkgName
)}`;
}
export function npmDistTagRm(tagName: string, pkgName: string): Message {
return `npm dist-tag rm ${pkgName} ${tagName}`;
}
export function npmDistTagAdd(
pkgName: string,
pkgVersion: string,
tagName: string
): Message {
return `npm dist-tag add ${pkgName}@${pkgVersion} ${tagName}`;
}
export function npmPublish(pkgName: string): Message {
return `npm publish ${pkgName}`;
}
export function npmInfo(pkgName: string): Message {
return `npm info ${pkgName}`;
}
export function npmInfo404(pkgName: string): Message {
return `Recieved 404 for npm info ${normalPkg(pkgName)}`;
}
export function lockingAllPackages(): Message {
return 'Attempting to get locks for all packages';
}
export function validatingProject(): Message {
return '[1/4] Validating project...';
}
export function installingProjectDependencies(): Message {
return '[2/4] Installing project dependencies...';
}
export function linkingWorkspaceDependencies(): Message {
return '[3/4] Linking workspace dependencies...';
}
export function linkingWorkspaceBinaries(): Message {
return '[4/4] Linking workspace binaries...';
}
export function publishingPackage(
pkgName: string,
pkgVersion: string
): Message {
return `Publishing ${normalPkg(pkgName)} at ${goodVer(pkgVersion)}`;
}
export function noUnpublishedPackagesToPublish(): Message {
return 'No unpublished packages to publish';
}
export function willPublishUnpublishedPackage(
pkgName: string,
pkgLocalVersion: string
): Message {
return `${pkgName} is being published at version ${pkgLocalVersion} because it is not yet published`;
}
export function willPublishPackage(
pkgLocalVersion: string,
pkgPublishedVersion: string,
pkgName: string
): Message {
return `${pkgName} is being published because our local version (${pkgLocalVersion}) is ahead of npm's (${pkgPublishedVersion})`;
}
export function willNotPublishPackage(
pkgLocalVersion: string,
pkgPublishedVersion: string,
pkgName: string
): Message {
return `${pkgName} is not being published because version ${pkgPublishedVersion} is already published on npm and we are trying to publish version ${pkgLocalVersion}`;
}
export function successfullyPublishedPackage(
pkgName: string,
pkgVersion: string
): Message {
return `Successfully published ${pkgName}@${pkgVersion}`;
}
export function failedToPublishPackage(pkgName: string): Message {
return `Failed to publish ${pkgName}`;
}
export function couldNotBeNormalized(): Message {
return 'The following packages could not be normalized:';
}
export function installedAndLinkedWorkspaces(): Message {
return 'Installed and linked workspaces.';
}
export function cannotInstallWorkspaceInProject(pkgName: string): Message {
return `Cannot install workspace "${pkgName}" as a dependency of a project`;
}
export function cannotUpgradeWorkspaceDependencyInProject(
pkgName: string
): Message {
return `Cannot upgrade workspace "${pkgName}" as a dependency of a project.
All the workspaces are symlinked, upgrading workspce dependency is invalid.`;
}
export function errorParsingJSON(filePath: string): Message {
return `Error parsing JSON in file:\n${filePath}`;
}
// TODO: This message actually only makes sense when using changeset commands, so should probably
// be rethought out once `bolt version`, etc is ready
export function invalidBoltWorkspacesFromUpdate(
name: string,
depName: string,
depRange: string,
newVersion: string
): Message {
return `${importantSeparator}
${name} has a dependency on ${depName} at ${depRange}, however the new version of ${newVersion} leaves this range.
You will need to make a new changeset that includes an update to ${name}
${importantSeparator}`;
}
export function unableToInstall(): Message {
return `Project is invalid, bolt is unable to install`;
}
export function cannotInitConfigMissingPkgJSON(filePath: string): Message {
let basePath = filePath.replace(/.package\.json$/, '');
return `This folder does not contain a package.json:\n${basePath}
Sometimes this is caused by incomplete packages or switching branches.
Try removing the directory or fixing the package and run bolt again.`;
}
export function unsafeCycles(): Message {
return 'Task ran with unsafe dependency cycles in workspaces.';
}
export function linkInternalPackage(internalPackageName: string): Message {
return `Cannot link project package (${internalPackageName}), as these are already linked`;
}
export function unlinkInternalPackage(internalPackageName: string): Message {
return `Cannot unlink project package (${internalPackageName})`;
}
export function errorWorkspaceUpgrade(): Message {
return `${chalk.red.bold(
'[bolt workspace upgrade]'
)} Unable to upgrade dependencies for a single workspace.
In order to upgrade a dependency [across all the workspaces] please run ${cmd(
'"bolt upgrade [...args]"'
)} or ${cmd('"bolt workspaces upgrade [...args]"')}`;
}
export function errorWorkspacesUpgrade(filterOpts: Array<string>): Message {
return `${chalk.red.bold(
'[bolt workspaces upgrade]'
)} Unable to upgrade dependencies for a single or some workspace.
Therefore, flags ${chalk.red.bold(
filterOpts.join(' ')
)} are not applicable here.
In order to upgrade a dependency please run without filter flags - ${cmd(
'"bolt upgrade [...args]"'
)} or ${cmd('"bolt workspaces upgrade [...args]"')}`;
}
export function noNeedToSymlinkInternalDependency(): Message {
return `Internal packages are symlinked, there is no need update them`;
}
export function taskRunningAcrossCINodes(
nodes: number,
count: number,
total: number
): Message {
return `Task is being split across ${nodes} nodes. Current node running across ${count} of ${total} workspaces`;
}
export function taskFailed(
numFailures: number,
failuresWithMsg: string[],
packageNames: string[]
): Message {
return `${numFailures} tasks failed for ${String(
packageNames
)}.\n${failuresWithMsg.join('\n')}`;
}