modpack-lock 0.6.2 → 0.7.0
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/README.md +15 -14
- package/build/cli.d.ts +3 -0
- package/build/cli.d.ts.map +1 -0
- package/build/cli.js +257 -0
- package/build/cli.js.map +1 -0
- package/build/config/api.d.ts +27 -0
- package/build/config/api.d.ts.map +1 -0
- package/{src → build}/config/api.js +2 -14
- package/build/config/api.js.map +1 -0
- package/build/config/constants.d.ts +17 -0
- package/build/config/constants.d.ts.map +1 -0
- package/{src → build}/config/constants.js +10 -10
- package/build/config/constants.js.map +1 -0
- package/build/config/defaults.d.ts +16 -0
- package/build/config/defaults.d.ts.map +1 -0
- package/build/config/defaults.js +60 -0
- package/build/config/defaults.js.map +1 -0
- package/build/config/files.d.ts +11 -0
- package/build/config/files.d.ts.map +1 -0
- package/{src → build}/config/files.js +1 -4
- package/build/config/files.js.map +1 -0
- package/build/config/index.d.ts +7 -0
- package/build/config/index.d.ts.map +1 -0
- package/{src → build}/config/index.js +1 -0
- package/build/config/index.js.map +1 -0
- package/build/config/options.d.ts +8 -0
- package/build/config/options.d.ts.map +1 -0
- package/{src → build}/config/options.js +7 -6
- package/build/config/options.js.map +1 -0
- package/build/config/strings.d.ts +35 -0
- package/build/config/strings.d.ts.map +1 -0
- package/{src → build}/config/strings.js +14 -19
- package/build/config/strings.js.map +1 -0
- package/build/directory_scanning.d.ts +26 -0
- package/build/directory_scanning.d.ts.map +1 -0
- package/{src → build}/directory_scanning.js +23 -36
- package/build/directory_scanning.js.map +1 -0
- package/build/generate_gitignore.d.ts +9 -0
- package/build/generate_gitignore.d.ts.map +1 -0
- package/{src → build}/generate_gitignore.js +21 -35
- package/build/generate_gitignore.js.map +1 -0
- package/build/generate_json.d.ts +11 -0
- package/build/generate_json.d.ts.map +1 -0
- package/{src → build}/generate_json.js +40 -39
- package/build/generate_json.js.map +1 -0
- package/build/generate_license.d.ts +11 -0
- package/build/generate_license.d.ts.map +1 -0
- package/build/generate_license.js +54 -0
- package/build/generate_license.js.map +1 -0
- package/build/generate_lockfile.d.ts +14 -0
- package/build/generate_lockfile.d.ts.map +1 -0
- package/{src → build}/generate_lockfile.js +19 -69
- package/build/generate_lockfile.js.map +1 -0
- package/build/generate_readme.d.ts +9 -0
- package/build/generate_readme.d.ts.map +1 -0
- package/{src → build}/generate_readme.js +46 -72
- package/build/generate_readme.js.map +1 -0
- package/build/github_interactions.d.ts +14 -0
- package/build/github_interactions.d.ts.map +1 -0
- package/{src → build}/github_interactions.js +16 -19
- package/build/github_interactions.js.map +1 -0
- package/build/logger.d.ts +96 -0
- package/build/logger.d.ts.map +1 -0
- package/{src → build}/logger.js +47 -55
- package/build/logger.js.map +1 -0
- package/build/modpack-lock.d.ts +25 -0
- package/build/modpack-lock.d.ts.map +1 -0
- package/{src → build}/modpack-lock.js +12 -38
- package/build/modpack-lock.js.map +1 -0
- package/build/modrinth_interactions.d.ts +31 -0
- package/build/modrinth_interactions.d.ts.map +1 -0
- package/{src → build}/modrinth_interactions.js +67 -55
- package/build/modrinth_interactions.js.map +1 -0
- package/build/types/Jsonfile.d.ts +15 -0
- package/build/types/Jsonfile.d.ts.map +1 -0
- package/build/types/Jsonfile.js +2 -0
- package/build/types/Jsonfile.js.map +1 -0
- package/build/types/Lockfile.d.ts +39 -0
- package/build/types/Lockfile.d.ts.map +1 -0
- package/build/types/Lockfile.js +2 -0
- package/build/types/Lockfile.js.map +1 -0
- package/build/types/ModpackInfo.d.ts +28 -0
- package/build/types/ModpackInfo.d.ts.map +1 -0
- package/build/types/ModpackInfo.js +2 -0
- package/build/types/ModpackInfo.js.map +1 -0
- package/build/types/OptionalFileOptions.d.ts +8 -0
- package/build/types/OptionalFileOptions.d.ts.map +1 -0
- package/build/types/OptionalFileOptions.js +2 -0
- package/build/types/OptionalFileOptions.js.map +1 -0
- package/build/types/contentFiles.d.ts +24 -0
- package/build/types/contentFiles.d.ts.map +1 -0
- package/build/types/contentFiles.js +2 -0
- package/build/types/contentFiles.js.map +1 -0
- package/build/types/githubResponses.d.ts +17 -0
- package/build/types/githubResponses.d.ts.map +1 -0
- package/build/types/githubResponses.js +2 -0
- package/build/types/githubResponses.js.map +1 -0
- package/build/types/index.d.ts +9 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +2 -0
- package/build/types/index.js.map +1 -0
- package/build/types/modrinthResponses.d.ts +135 -0
- package/build/types/modrinthResponses.d.ts.map +1 -0
- package/build/types/modrinthResponses.js +2 -0
- package/build/types/modrinthResponses.js.map +1 -0
- package/build/types/options.d.ts +70 -0
- package/build/types/options.d.ts.map +1 -0
- package/build/types/options.js +2 -0
- package/build/types/options.js.map +1 -0
- package/build/user_prompts.d.ts +16 -0
- package/build/user_prompts.d.ts.map +1 -0
- package/build/user_prompts.js +132 -0
- package/build/user_prompts.js.map +1 -0
- package/package.json +13 -6
- package/src/cli.js +0 -310
- package/src/config/defaults.js +0 -66
- package/src/config/types.js +0 -76
- package/src/generate_license.js +0 -54
- package/src/modpack_info.js +0 -200
package/src/modpack_info.js
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import prompts from "prompts";
|
|
2
|
-
import slugify from "slugify";
|
|
3
|
-
import * as config from "./config/index.js";
|
|
4
|
-
import {getLicenseList, getLicenseText} from "./github_interactions.js";
|
|
5
|
-
import {getMinecraftVersions, getModloaders} from "./modrinth_interactions.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {import('./config/types.js').ModpackInfo} ModpackInfo
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Capitalizes a string
|
|
13
|
-
*/
|
|
14
|
-
function capitalize(string) {
|
|
15
|
-
return `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Validate that a value is not empty
|
|
20
|
-
*/
|
|
21
|
-
function validateNotEmpty(value, field) {
|
|
22
|
-
if (value === undefined || value?.trim().length === 0) {
|
|
23
|
-
return `${field} cannot be empty`;
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns a required text prompt
|
|
30
|
-
*/
|
|
31
|
-
function requiredText(name, message, initial) {
|
|
32
|
-
return {
|
|
33
|
-
type: "text",
|
|
34
|
-
name: name,
|
|
35
|
-
message: `${capitalize(message)}`,
|
|
36
|
-
initial: initial,
|
|
37
|
-
validate: (value) => {
|
|
38
|
-
return validateNotEmpty(value, name);
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Returns an optional text prompt
|
|
45
|
-
*/
|
|
46
|
-
function optionalText(name, message, initial) {
|
|
47
|
-
return {
|
|
48
|
-
type: "text",
|
|
49
|
-
name: name,
|
|
50
|
-
message: `${capitalize(message)}`,
|
|
51
|
-
initial: initial,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Get an other answer from the user
|
|
57
|
-
*/
|
|
58
|
-
async function getOtherAnswer(value, message, initial) {
|
|
59
|
-
if (value && value !== config.OTHER_OPTION.value) {
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
const question = await prompts(requiredText("other", message, initial), config.PROMPTS_OPTIONS);
|
|
63
|
-
|
|
64
|
-
return question.other || config.OTHER_OPTION.value;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Returns a required autocomplete prompt with a fallback to the other option
|
|
69
|
-
*/
|
|
70
|
-
function requiredAutocomplete(name, message, initial, choices, defaultValue) {
|
|
71
|
-
initial = initial || defaultValue || config.OTHER_OPTION.value;
|
|
72
|
-
if (initial && !choices.some((choice) => choice.value === initial)) {
|
|
73
|
-
choices.push({title: initial, value: initial});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
type: "autocomplete",
|
|
78
|
-
name: name,
|
|
79
|
-
message: `${capitalize(message)}`,
|
|
80
|
-
initial: initial,
|
|
81
|
-
choices: choices,
|
|
82
|
-
fallback: config.OTHER_OPTION.value,
|
|
83
|
-
format: async (value) => {
|
|
84
|
-
return await getOtherAnswer(value, ` └─ Other ${message}`, initial);
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Returns an confirmation prompt to generate an optional file
|
|
91
|
-
*/
|
|
92
|
-
function fileGenerationConfirm(name, message, showPrompt) {
|
|
93
|
-
return {
|
|
94
|
-
type: showPrompt ? "confirm" : null,
|
|
95
|
-
name: name,
|
|
96
|
-
message: `${capitalize(message)}`,
|
|
97
|
-
initial: true,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Get user input for modpack information
|
|
103
|
-
* @param {ModpackInfo} defaults - The initial/default modpack information
|
|
104
|
-
* @returns {Promise<ModpackInfo>} The modpack information from the user
|
|
105
|
-
*/
|
|
106
|
-
export async function promptUserForInfo(defaults = {}) {
|
|
107
|
-
const licenseList = await getLicenseList();
|
|
108
|
-
const minecraftVersions = await getMinecraftVersions();
|
|
109
|
-
const modloaders = await getModloaders();
|
|
110
|
-
let answers = await prompts(
|
|
111
|
-
[
|
|
112
|
-
requiredText("name", config.infoFields.name.prompt, defaults.name),
|
|
113
|
-
requiredText(
|
|
114
|
-
"version",
|
|
115
|
-
config.infoFields.version.prompt,
|
|
116
|
-
defaults.version || config.DEFAULT_MODPACK_VERSION,
|
|
117
|
-
),
|
|
118
|
-
requiredText("id", config.infoFields.id.prompt, (prev, values) =>
|
|
119
|
-
slugify(defaults.id || values.name, config.SLUGIFY_OPTIONS),
|
|
120
|
-
),
|
|
121
|
-
optionalText("description", config.infoFields.description.prompt, defaults.description),
|
|
122
|
-
requiredText("author", config.infoFields.author.prompt, defaults.author),
|
|
123
|
-
optionalText(
|
|
124
|
-
"projectUrl",
|
|
125
|
-
config.infoFields.projectUrl.prompt,
|
|
126
|
-
(prev, values) => defaults.projectUrl || config.DEFAULT_PROJECT_URL(values.id),
|
|
127
|
-
),
|
|
128
|
-
optionalText(
|
|
129
|
-
"sourceUrl",
|
|
130
|
-
config.infoFields.sourceUrl.prompt,
|
|
131
|
-
(prev, values) => defaults.sourceUrl || config.DEFAULT_SOURCE_URL(values.id, values.author),
|
|
132
|
-
),
|
|
133
|
-
requiredAutocomplete(
|
|
134
|
-
"license",
|
|
135
|
-
config.infoFields.license.prompt,
|
|
136
|
-
defaults.license,
|
|
137
|
-
licenseList,
|
|
138
|
-
config.DEFAULT_MODPACK_LICENSE,
|
|
139
|
-
),
|
|
140
|
-
requiredAutocomplete(
|
|
141
|
-
"modloader",
|
|
142
|
-
config.infoFields.modloader.prompt,
|
|
143
|
-
defaults.modloader,
|
|
144
|
-
modloaders,
|
|
145
|
-
config.FALLBACK_MODLOADERS[0].value,
|
|
146
|
-
),
|
|
147
|
-
optionalText(
|
|
148
|
-
"targetModloaderVersion",
|
|
149
|
-
config.infoFields.targetModloaderVersion.prompt,
|
|
150
|
-
defaults.targetModloaderVersion,
|
|
151
|
-
),
|
|
152
|
-
requiredAutocomplete(
|
|
153
|
-
"targetMinecraftVersion",
|
|
154
|
-
config.infoFields.targetMinecraftVersion.prompt,
|
|
155
|
-
defaults.targetMinecraftVersion,
|
|
156
|
-
minecraftVersions,
|
|
157
|
-
minecraftVersions[0].value,
|
|
158
|
-
),
|
|
159
|
-
],
|
|
160
|
-
config.PROMPTS_OPTIONS,
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
return answers;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Prompt the user about adding the license text to the modpack
|
|
168
|
-
* @param {ModpackInfo} modpackInfo - The modpack information
|
|
169
|
-
* @returns {Promise<Object>} The answers from the user
|
|
170
|
-
*/
|
|
171
|
-
export async function promptUserAboutOptionalFiles(modpackInfo, defaults = {}) {
|
|
172
|
-
const licenseText = await getLicenseText(modpackInfo.license);
|
|
173
|
-
const answers = await prompts(
|
|
174
|
-
[
|
|
175
|
-
fileGenerationConfirm(
|
|
176
|
-
"addLicense",
|
|
177
|
-
`${config.fileFields.addLicense.prompt}?`,
|
|
178
|
-
licenseText && defaults.addLicense === undefined,
|
|
179
|
-
),
|
|
180
|
-
fileGenerationConfirm(
|
|
181
|
-
"addReadme",
|
|
182
|
-
`${config.fileFields.addReadme.prompt}?`,
|
|
183
|
-
defaults.addReadme === undefined,
|
|
184
|
-
),
|
|
185
|
-
fileGenerationConfirm(
|
|
186
|
-
"addGitignore",
|
|
187
|
-
`${config.fileFields.addGitignore.prompt}?`,
|
|
188
|
-
defaults.addGitignore === undefined,
|
|
189
|
-
),
|
|
190
|
-
],
|
|
191
|
-
config.PROMPTS_OPTIONS,
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
answers.addLicense =
|
|
195
|
-
answers.addLicense === undefined ? (licenseText ? defaults.addLicense : false) : answers.addLicense;
|
|
196
|
-
answers.addReadme = answers.addReadme === undefined ? defaults.addReadme : answers.addReadme;
|
|
197
|
-
answers.addGitignore = answers.addGitignore === undefined ? defaults.addGitignore : answers.addGitignore;
|
|
198
|
-
|
|
199
|
-
return answers;
|
|
200
|
-
}
|