forked from preconstruct/preconstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.ts
66 lines (60 loc) 路 2.75 KB
/
messages.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
import { PKG_JSON_CONFIG_FIELD } from "./constants";
import { createPromptConfirmLoader } from "./prompt";
import chalk from "chalk";
type Field = "main" | "module" | "browser" | "umd:main" | "worker";
export let errors = {
noSource: (source: string) =>
`no source file was provided, please create a file at ${source} or specify a custom source file with the ${PKG_JSON_CONFIG_FIELD} source option`,
deniedWriteMainField: "changing the main field is required to build",
invalidField: (field: Field, found: unknown, expected: unknown) =>
`${field} field ${
found === undefined
? chalk.red("was not found")
: `is invalid, found \`${chalk.red(JSON.stringify(found))}\``
}, expected \`${chalk.green(JSON.stringify(expected))}\``,
umdNameNotSpecified: `the umd:main field is specified but a umdName option is not specified. please add it to the ${PKG_JSON_CONFIG_FIELD} field in your package.json`,
noEntrypointPkgJson: "There is a missing package.json for an entrypoint",
noEntrypoints:
"packages must have at least one entrypoint, this package has no entrypoints",
fieldMustExistInAllEntrypointsIfExistsDeclinedFixDuringInit: (field: Field) =>
`all entrypoints in a package must have the same fields and one entrypoint in this package has a ${field} field but you've declined the fix`,
};
export let confirms = {
writeMainField: createPromptConfirmLoader(
"preconstruct is going to change the main field in your package.json, are you okay with that?"
),
writeModuleField: createPromptConfirmLoader(
"would you like to generate module builds? this will write to the module field in your package.json"
),
fixModuleField: createPromptConfirmLoader(
"would you like to fix the module field?"
),
fixUmdBuild: createPromptConfirmLoader(
"would you like to fix the umd field?"
),
fixBrowserField: createPromptConfirmLoader(
"would you like to fix the browser build?"
),
fixWorkerField: createPromptConfirmLoader(
"would you like to fix the worker build?"
),
createEntrypointPkgJson: createPromptConfirmLoader(
"A package.json file does not exist for this entrypoint, would you like to create one automatically?"
),
createEntrypoint: createPromptConfirmLoader(
"This glob does not match anything, would you like to create an entrypoint for it?"
),
};
export let inputs = {
getUmdName: "what should the name used for UMD bundles be?",
getSource: "what should the source file for this entrypoint be?",
};
export let infos = {
validField: (field: Field) => `${field} field is valid`,
validEntrypoint: "a valid entry point exists.",
validPackageEntrypoints: "package entrypoints are valid",
};
export let successes = {
validProject: "project is valid!",
startedWatching: "started watching!",
};