modpack-lock 0.6.1 → 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.
Files changed (119) hide show
  1. package/README.md +15 -14
  2. package/build/cli.d.ts +3 -0
  3. package/build/cli.d.ts.map +1 -0
  4. package/build/cli.js +257 -0
  5. package/build/cli.js.map +1 -0
  6. package/build/config/api.d.ts +27 -0
  7. package/build/config/api.d.ts.map +1 -0
  8. package/{src → build}/config/api.js +2 -14
  9. package/build/config/api.js.map +1 -0
  10. package/build/config/constants.d.ts +17 -0
  11. package/build/config/constants.d.ts.map +1 -0
  12. package/{src → build}/config/constants.js +10 -10
  13. package/build/config/constants.js.map +1 -0
  14. package/build/config/defaults.d.ts +16 -0
  15. package/build/config/defaults.d.ts.map +1 -0
  16. package/build/config/defaults.js +60 -0
  17. package/build/config/defaults.js.map +1 -0
  18. package/build/config/files.d.ts +11 -0
  19. package/build/config/files.d.ts.map +1 -0
  20. package/{src → build}/config/files.js +1 -4
  21. package/build/config/files.js.map +1 -0
  22. package/build/config/index.d.ts +7 -0
  23. package/build/config/index.d.ts.map +1 -0
  24. package/{src → build}/config/index.js +1 -0
  25. package/build/config/index.js.map +1 -0
  26. package/build/config/options.d.ts +8 -0
  27. package/build/config/options.d.ts.map +1 -0
  28. package/{src → build}/config/options.js +7 -6
  29. package/build/config/options.js.map +1 -0
  30. package/build/config/strings.d.ts +35 -0
  31. package/build/config/strings.d.ts.map +1 -0
  32. package/{src → build}/config/strings.js +14 -19
  33. package/build/config/strings.js.map +1 -0
  34. package/build/directory_scanning.d.ts +26 -0
  35. package/build/directory_scanning.d.ts.map +1 -0
  36. package/{src → build}/directory_scanning.js +23 -36
  37. package/build/directory_scanning.js.map +1 -0
  38. package/build/generate_gitignore.d.ts +9 -0
  39. package/build/generate_gitignore.d.ts.map +1 -0
  40. package/{src → build}/generate_gitignore.js +23 -37
  41. package/build/generate_gitignore.js.map +1 -0
  42. package/build/generate_json.d.ts +11 -0
  43. package/build/generate_json.d.ts.map +1 -0
  44. package/{src → build}/generate_json.js +40 -39
  45. package/build/generate_json.js.map +1 -0
  46. package/build/generate_license.d.ts +11 -0
  47. package/build/generate_license.d.ts.map +1 -0
  48. package/build/generate_license.js +54 -0
  49. package/build/generate_license.js.map +1 -0
  50. package/build/generate_lockfile.d.ts +14 -0
  51. package/build/generate_lockfile.d.ts.map +1 -0
  52. package/{src → build}/generate_lockfile.js +19 -69
  53. package/build/generate_lockfile.js.map +1 -0
  54. package/build/generate_readme.d.ts +9 -0
  55. package/build/generate_readme.d.ts.map +1 -0
  56. package/{src → build}/generate_readme.js +50 -76
  57. package/build/generate_readme.js.map +1 -0
  58. package/build/github_interactions.d.ts +14 -0
  59. package/build/github_interactions.d.ts.map +1 -0
  60. package/{src → build}/github_interactions.js +16 -20
  61. package/build/github_interactions.js.map +1 -0
  62. package/build/logger.d.ts +96 -0
  63. package/build/logger.d.ts.map +1 -0
  64. package/{src → build}/logger.js +47 -55
  65. package/build/logger.js.map +1 -0
  66. package/build/modpack-lock.d.ts +25 -0
  67. package/build/modpack-lock.d.ts.map +1 -0
  68. package/{src → build}/modpack-lock.js +12 -38
  69. package/build/modpack-lock.js.map +1 -0
  70. package/build/modrinth_interactions.d.ts +31 -0
  71. package/build/modrinth_interactions.d.ts.map +1 -0
  72. package/{src → build}/modrinth_interactions.js +69 -59
  73. package/build/modrinth_interactions.js.map +1 -0
  74. package/build/types/Jsonfile.d.ts +15 -0
  75. package/build/types/Jsonfile.d.ts.map +1 -0
  76. package/build/types/Jsonfile.js +2 -0
  77. package/build/types/Jsonfile.js.map +1 -0
  78. package/build/types/Lockfile.d.ts +39 -0
  79. package/build/types/Lockfile.d.ts.map +1 -0
  80. package/build/types/Lockfile.js +2 -0
  81. package/build/types/Lockfile.js.map +1 -0
  82. package/build/types/ModpackInfo.d.ts +28 -0
  83. package/build/types/ModpackInfo.d.ts.map +1 -0
  84. package/build/types/ModpackInfo.js +2 -0
  85. package/build/types/ModpackInfo.js.map +1 -0
  86. package/build/types/OptionalFileOptions.d.ts +8 -0
  87. package/build/types/OptionalFileOptions.d.ts.map +1 -0
  88. package/build/types/OptionalFileOptions.js +2 -0
  89. package/build/types/OptionalFileOptions.js.map +1 -0
  90. package/build/types/contentFiles.d.ts +24 -0
  91. package/build/types/contentFiles.d.ts.map +1 -0
  92. package/build/types/contentFiles.js +2 -0
  93. package/build/types/contentFiles.js.map +1 -0
  94. package/build/types/githubResponses.d.ts +17 -0
  95. package/build/types/githubResponses.d.ts.map +1 -0
  96. package/build/types/githubResponses.js +2 -0
  97. package/build/types/githubResponses.js.map +1 -0
  98. package/build/types/index.d.ts +9 -0
  99. package/build/types/index.d.ts.map +1 -0
  100. package/build/types/index.js +2 -0
  101. package/build/types/index.js.map +1 -0
  102. package/build/types/modrinthResponses.d.ts +135 -0
  103. package/build/types/modrinthResponses.d.ts.map +1 -0
  104. package/build/types/modrinthResponses.js +2 -0
  105. package/build/types/modrinthResponses.js.map +1 -0
  106. package/build/types/options.d.ts +70 -0
  107. package/build/types/options.d.ts.map +1 -0
  108. package/build/types/options.js +2 -0
  109. package/build/types/options.js.map +1 -0
  110. package/build/user_prompts.d.ts +16 -0
  111. package/build/user_prompts.d.ts.map +1 -0
  112. package/build/user_prompts.js +132 -0
  113. package/build/user_prompts.js.map +1 -0
  114. package/package.json +19 -9
  115. package/src/cli.js +0 -310
  116. package/src/config/defaults.js +0 -66
  117. package/src/config/types.js +0 -76
  118. package/src/generate_license.js +0 -54
  119. package/src/modpack_info.js +0 -200
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "modpack-lock",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Creates a modpack lockfile for files hosted on Modrinth (mods, resource packs, shaders and datapacks)",
5
5
  "bugs": {
6
6
  "url": "https://github.com/nickesc/modpack-lock/issues"
@@ -13,9 +13,9 @@
13
13
  "license": "MIT",
14
14
  "author": "N. Escobar <nick@nickesc.io> (https://nickesc.github.io/)",
15
15
  "type": "module",
16
- "main": "src/modpack-lock.js",
16
+ "main": "build/modpack-lock.js",
17
17
  "bin": {
18
- "modpack-lock": "src/cli.js"
18
+ "modpack-lock": "build/cli.js"
19
19
  },
20
20
  "keywords": [
21
21
  "modrinth",
@@ -27,26 +27,36 @@
27
27
  "node": ">=22.0.0"
28
28
  },
29
29
  "scripts": {
30
+ "build": "tsc",
30
31
  "test": "vitest --run",
31
- "start": "node src/cli.js",
32
+ "start": "tsx src/cli.ts",
32
33
  "docs": "typedoc",
33
- "modpack-lock": "node src/cli.js"
34
+ "modpack-lock": "tsx src/cli.ts",
35
+ "prepare": "npm run build"
34
36
  },
35
37
  "files": [
36
38
  "README.md",
37
39
  "LICENSE",
38
40
  "package.json",
39
- "src/**/*.js"
41
+ "build/**/*"
40
42
  ],
41
43
  "dependencies": {
42
- "commander": "^14.0.2",
44
+ "@sindresorhus/slugify": "^3.0.0",
45
+ "commander": "^14.0.3",
43
46
  "prompts": "^2.4.2",
44
47
  "slugify": "^1.6.6"
45
48
  },
46
49
  "devDependencies": {
47
- "@vitest/coverage-v8": "^4.0.16",
48
- "typedoc": "^0.28.16",
50
+ "@eslint/js": "^10.0.1",
51
+ "@types/node": "^25.3.3",
52
+ "@types/prompts": "^2.4.9",
53
+ "@vitest/coverage-v8": "^4.0.18",
54
+ "eslint": "^10.0.0",
55
+ "globals": "^17.3.0",
56
+ "tsx": "^4.21.0",
57
+ "typedoc": "^0.28.17",
49
58
  "typedoc-github-theme": "^0.3.1",
59
+ "typescript": "^5.9.3",
50
60
  "unzipper": "^0.12.3",
51
61
  "vitest": "^4.0.16"
52
62
  }
package/src/cli.js DELETED
@@ -1,310 +0,0 @@
1
- #!/usr/bin/env NODE_OPTIONS=--no-warnings node
2
-
3
- import {Command} from "commander";
4
- import slugify from "slugify";
5
- import path from "path";
6
- import {spawn} from "child_process";
7
- import {generateLockfile, printLockfileSummary} from "./generate_lockfile.js";
8
- import {generateReadmeFiles} from "./generate_readme.js";
9
- import {generateGitignoreRules} from "./generate_gitignore.js";
10
- import {generateModpackFiles} from "./modpack-lock.js";
11
- import {promptUserForInfo, promptUserAboutOptionalFiles} from "./modpack_info.js";
12
- import {getModpackInfo} from "./directory_scanning.js";
13
- import * as config from "./config/index.js";
14
- import pkg from "../package.json" with {type: "json"};
15
- import {logm, styleText} from "./logger.js";
16
-
17
- const modpackLock = new Command("modpack-lock");
18
-
19
- /**
20
- * Merge modpack info with priority: options > existingInfo > defaults
21
- * Preserves all fields from existingInfo
22
- */
23
- function mergeModpackInfo(existingInfo, options, defaults) {
24
- const result = {};
25
- for (const [key, defaultValue] of Object.entries(defaults)) {
26
- result[key] = options[key] || existingInfo?.[key] || defaultValue;
27
- }
28
-
29
- // Then, add any fields from existingInfo that aren't in defaults
30
- if (existingInfo) {
31
- for (const [key, value] of Object.entries(existingInfo)) {
32
- if (!(key in defaults)) {
33
- result[key] = value;
34
- }
35
- }
36
- }
37
-
38
- return result;
39
- }
40
-
41
- modpackLock
42
- .name(pkg.name)
43
- .description(pkg.description)
44
- .summary("Create a modpack lockfile")
45
- .optionsGroup(config.headings.options)
46
- .option("-p, --path <path>", "Path to the modpack directory")
47
- .option("-d, --dry-run", "Dry-run mode - no files will be written")
48
- .optionsGroup(config.headings.generation)
49
- .option("-l, --licenseFile", config.fileFields.addLicense.option)
50
- .option("-g, --gitignore", config.fileFields.addGitignore.option)
51
- .option("-r, --readme", config.fileFields.addReadme.option)
52
- .optionsGroup(config.headings.logging)
53
- .option("-q, --quiet", "Quiet mode - only show errors and warnings")
54
- .option("-s, --silent", "Silent mode - no output")
55
- .optionsGroup(config.headings.information)
56
- .helpOption("-h, --help", `display help for ${pkg.name}`)
57
- .version(pkg.version, "-V")
58
- .action(async (options) => {
59
- try {
60
- const currDir = options.path || process.cwd();
61
-
62
- logm.quietFromOptions(options);
63
-
64
- const modpackInfo = await getModpackInfo(currDir);
65
- if (modpackInfo) {
66
- const lockfile = await generateModpackFiles(modpackInfo, currDir, options);
67
- printLockfileSummary(lockfile);
68
- } else {
69
- // Warn if license option is passed but no modpack.json exists
70
- if (options.licenseFile) {
71
- logm.warn(
72
- `License generation requires a ${config.MODPACK_JSON_NAME} file. Skipping license generation.`,
73
- );
74
- }
75
-
76
- // Generate lockfile
77
- const lockfile = await generateLockfile(currDir, options);
78
-
79
- if (options.gitignore || options.readme) {
80
- logm.header("Generating Optional Files");
81
- }
82
-
83
- // Generate gitignore if requested
84
- if (options.gitignore) {
85
- await generateGitignoreRules(lockfile, currDir, options);
86
- }
87
-
88
- // Generate README files if requested
89
- if (options.readme) {
90
- await generateReadmeFiles(lockfile, currDir, options);
91
- }
92
-
93
- printLockfileSummary(lockfile);
94
- }
95
- } catch (error) {
96
- logm.error(error);
97
- process.exitCode = 1;
98
- }
99
- });
100
-
101
- modpackLock
102
- .command("init")
103
- .description(
104
- `Initialize a modpack with a ${config.MODPACK_JSON_NAME} file and a ${config.MODPACK_LOCKFILE_NAME} lockfile.`,
105
- )
106
- .optionsGroup(config.headings.options)
107
- .option("-f, --folder <path>", "Path to the modpack directory")
108
- .option("-n, --noninteractive", "Non-interactive mode - must provide options for required fields")
109
- .option("--add-license", config.fileFields.addLicense.option)
110
- .option("--add-gitignore", config.fileFields.addGitignore.option)
111
- .option("--add-readme", config.fileFields.addReadme.option)
112
- .optionsGroup(config.headings.packInfo)
113
- .option("--name <name>", config.infoFields.name.option)
114
- .option("--version <version>", config.infoFields.version.option)
115
- .option("--id <id>", config.infoFields.id.option)
116
- .option("--description <description>", config.infoFields.description.option)
117
- .option("--author <author>", config.infoFields.author.option)
118
- .option("--projectUrl <projectUrl>", config.infoFields.projectUrl.option)
119
- .option("--sourceUrl <sourceUrl>", config.infoFields.sourceUrl.option)
120
- .option("--license <license>", config.infoFields.license.option)
121
- .option("--modloader <modloader>", config.infoFields.modloader.option)
122
- .option("--targetModloaderVersion <targetModloaderVersion>", config.infoFields.targetModloaderVersion.option)
123
- .option("--targetMinecraftVersion <targetMinecraftVersion>", config.infoFields.targetMinecraftVersion.option)
124
- .optionsGroup(config.headings.information)
125
- .helpOption("-h, --help", `display help for ${pkg.name} init`)
126
- .action(async (options) => {
127
- options._init = true;
128
- const currDir = options.folder || process.cwd();
129
-
130
- let existingInfo = await getModpackInfo(currDir);
131
-
132
- if (options.noninteractive) {
133
- logm.quiet();
134
- if (
135
- (!options.author && !existingInfo?.author) ||
136
- (!options.modloader && !existingInfo?.modloader) ||
137
- (!options.targetMinecraftVersion && !existingInfo?.targetMinecraftVersion)
138
- ) {
139
- logm.error("Must provide options for required fields");
140
- process.exitCode = 1;
141
- return;
142
- } else {
143
- const defaultName = path.basename(currDir);
144
- const defaults = {
145
- name: defaultName,
146
- version: config.DEFAULT_MODPACK_VERSION,
147
- id: defaultName,
148
- description: "",
149
- author: options.author, // Required, no default
150
- projectUrl: "",
151
- sourceUrl: "",
152
- license: "",
153
- modloader: options.modloader, // Required, no default
154
- targetModloaderVersion: "",
155
- targetMinecraftVersion: options.targetMinecraftVersion, // Required, no default
156
- };
157
-
158
- const modpackInfo = mergeModpackInfo(existingInfo, options, defaults);
159
- modpackInfo.id = slugify(modpackInfo.id, config.SLUGIFY_OPTIONS);
160
-
161
- options.readme = options.addReadme;
162
- options.gitignore = options.addGitignore;
163
- options.licenseFile = options.addLicense;
164
-
165
- // generate the modpack files
166
- try {
167
- await generateModpackFiles(modpackInfo, currDir, options);
168
- } catch (error) {
169
- logm.error(error);
170
- process.exitCode = 1;
171
- }
172
- }
173
- } else {
174
- logm.info(logm.label("modpack-lock"), styleText(["bold", "italic", "blueBright"], "init"));
175
- logm.newline();
176
- logm.info(
177
- styleText(["dim"], "This utility will walk you through creating a"),
178
- config.MODPACK_JSON_NAME,
179
- styleText(["dim"], "file and a"),
180
- config.MODPACK_LOCKFILE_NAME,
181
- styleText(
182
- ["dim"],
183
- "lockfile. It only covers the most common items, and tries to guess sensible defaults.",
184
- ),
185
- );
186
- logm.newline();
187
- logm.info(
188
- styleText(["dim"], "See"),
189
- styleText(["white", "bgGray", "italic"], "modpack-lock init --help"),
190
- styleText(["dim"], "for definitive documentation on these fields and exactly what they do."),
191
- );
192
- logm.newline();
193
- logm.info(
194
- styleText(["dim"], "Press"),
195
- styleText(["yellow"], "^C"),
196
- styleText(["dim"], "at any time to quit."),
197
- );
198
- logm.newline();
199
- try {
200
- const defaults = {
201
- name: path.basename(currDir),
202
- version: config.DEFAULT_MODPACK_VERSION,
203
- id: undefined,
204
- description: undefined,
205
- author: undefined,
206
- projectUrl: undefined,
207
- sourceUrl: undefined,
208
- license: config.DEFAULT_MODPACK_LICENSE,
209
- modloader: undefined,
210
- targetModloaderVersion: undefined,
211
- targetMinecraftVersion: undefined,
212
- };
213
- const mergedDefaults = mergeModpackInfo(existingInfo, options, defaults);
214
-
215
- // prompt user for modpack information
216
- const userAnswers = await promptUserForInfo(mergedDefaults);
217
-
218
- // Preserve extra fields (e.g. scripts) from existing modpack.json
219
- const modpackInfo = {...mergedDefaults, ...userAnswers};
220
-
221
- // prompt user if they want to add the license text
222
- const optionalFiles = await promptUserAboutOptionalFiles(modpackInfo, options);
223
-
224
- logm.newline();
225
-
226
- // generate the modpack files
227
- options.readme = optionalFiles.addReadme;
228
- options.gitignore = optionalFiles.addGitignore;
229
- options.licenseFile = optionalFiles.addLicense;
230
- const lockfile = await generateModpackFiles(modpackInfo, currDir, options);
231
-
232
- printLockfileSummary(lockfile);
233
- } catch (error) {
234
- logm.error(error);
235
- process.exitCode = 1;
236
- }
237
- }
238
- });
239
-
240
- modpackLock
241
- .command("run")
242
- .description(`Run a script defined in the ${config.MODPACK_JSON_NAME} file's 'scripts' field`)
243
- .argument("<script>", "The name of the script to run")
244
- .optionsGroup(config.headings.options)
245
- .option("-f, --folder <path>", "Path to the modpack directory")
246
- .option("-D, --debug", "Debug mode -- show more information about how the command is being parsed")
247
- .optionsGroup(config.headings.information)
248
- .helpOption("-h, --help", `display help for ${pkg.name} run`)
249
- .allowExcessArguments(true)
250
- .allowUnknownOption(true)
251
- .action(async (script, options, command) => {
252
- options._run = true;
253
- try {
254
- if (options.debug) {
255
- logm.debug("COMMAND:", command);
256
- }
257
-
258
- const currDir = options.folder || process.cwd();
259
- const modpackInfo = await getModpackInfo(currDir);
260
-
261
- // verify neccecary files and information exist
262
- if (!modpackInfo) {
263
- throw new Error(`No ${config.MODPACK_JSON_NAME} file found`);
264
- }
265
- if (!modpackInfo.scripts) {
266
- throw new Error(`No scripts defined in ${config.MODPACK_JSON_NAME}`);
267
- }
268
- if (!modpackInfo.scripts[script]) {
269
- throw new Error(`Script ${script} not found in ${config.MODPACK_JSON_NAME}`);
270
- }
271
-
272
- // build the full command
273
- const scriptCommand = modpackInfo.scripts[script];
274
- const args = command.args ? command.args.slice(1) : [];
275
- const fullCommand = `${scriptCommand} ${args.join(" ")}`;
276
-
277
- // debug logging
278
- if (options.debug) {
279
- logm.debug("CURR DIR:", currDir);
280
- logm.debug("OPTIONS:", options);
281
- logm.debug("SCRIPT:", script);
282
- logm.debug("SCRIPT COMMAND:", scriptCommand);
283
- logm.debug("ARGS:", args);
284
- logm.debug("FULL COMMAND:", fullCommand);
285
- }
286
-
287
- // spawn the command
288
- const child = spawn(fullCommand, [], {
289
- shell: true,
290
- stdio: "inherit",
291
- cwd: currDir,
292
- });
293
-
294
- // preserve exit code on completion
295
- const exitCode = await new Promise((resolve) => {
296
- child.on("close", (code) => {
297
- resolve(code || 0);
298
- });
299
- });
300
- process.exitCode = exitCode;
301
- } catch (error) {
302
- logm.error(error.message);
303
- process.exitCode = 1;
304
- }
305
- });
306
-
307
- modpackLock.parseAsync().catch((error) => {
308
- logm.error(error);
309
- process.exit(1);
310
- });
@@ -1,66 +0,0 @@
1
- export const DEFAULT_MODPACK_VERSION = "1.0.0";
2
-
3
- export const DEFAULT_MODPACK_LICENSE = "mit";
4
-
5
- export const DEFAULT_PROJECT_URL = (id) => {
6
- return `https://modrinth.com/modpack/${id}`;
7
- };
8
- export const DEFAULT_SOURCE_URL = (id, author) => {
9
- return `https://github.com/${author}/${id}`;
10
- };
11
-
12
- /** All-Rights-Reserved license option */
13
- export const ALL_RIGHTS_RESERVED_LICENSE = {title: "All-Rights-Reserved", value: "all-rights-reserved"};
14
-
15
- /** Other option */
16
- export const OTHER_OPTION = {title: "Other", value: "other"};
17
-
18
- /** Fallback licenses */
19
- export const FALLBACK_LICENSES = [
20
- {title: "MIT", value: "mit"},
21
- {title: "Apache-2.0", value: "apache-2.0"},
22
- {title: "GPL-3.0", value: "gpl-3.0"},
23
- {title: "CC0-1.0", value: "cc0-1.0"},
24
- ];
25
-
26
- /** Fallback modloaders */
27
- export const FALLBACK_MODLOADERS = [
28
- {title: "fabric", value: "fabric"},
29
- {title: "forge", value: "forge"},
30
- {title: "neoforge", value: "neoforge"},
31
- {title: "paper", value: "paper"},
32
- {title: "purpur", value: "purpur"},
33
- {title: "quilt", value: "quilt"},
34
- {title: "sponge", value: "sponge"},
35
- {title: "spigot", value: "spigot"},
36
- {title: "vanilla", value: "vanilla"},
37
- ];
38
-
39
- /** Fallback target Minecraft versions */
40
- export const FALLBACK_TARGET_MINECRAFT_VERSIONS = [
41
- {title: "1.21.x", value: "1.21.x"},
42
- {title: "1.20.x", value: "1.20.x"},
43
- {title: "1.19.x", value: "1.19.x"},
44
- {title: "1.18.x", value: "1.18.x"},
45
- {title: "1.17.x", value: "1.17.x"},
46
- {title: "1.16.x", value: "1.16.x"},
47
- {title: "1.15.x", value: "1.15.x"},
48
- {title: "1.14.x", value: "1.14.x"},
49
- {title: "1.13.x", value: "1.13.x"},
50
- {title: "1.12.x", value: "1.12.x"},
51
- {title: "1.11.x", value: "1.11.x"},
52
- {title: "1.10.x", value: "1.10.x"},
53
- {title: "1.9.x", value: "1.9.x"},
54
- {title: "1.8.x", value: "1.8.x"},
55
- {title: "1.7.x", value: "1.7.x"},
56
- {title: "1.6.x", value: "1.6.x"},
57
- {title: "1.5.x", value: "1.5.x"},
58
- {title: "1.4.x", value: "1.4.x"},
59
- {title: "1.3.x", value: "1.3.x"},
60
- {title: "1.2.x", value: "1.2.x"},
61
- {title: "1.1.x", value: "1.1.x"},
62
- {title: "1.0.x", value: "1.0.x"},
63
- {title: "snapshot", value: "snapshot"},
64
- {title: "beta", value: "beta"},
65
- {title: "alpha", value: "alpha"},
66
- ];
@@ -1,76 +0,0 @@
1
- /**
2
- * @typedef {Object} ModpackInfo
3
- * Contains information about the modpack that is not dependent on the lockfile.
4
- * @property {string} name - The name of the modpack (Required)
5
- * @property {string} version - The version of the modpack (Required)
6
- * @property {string} description - The description of the modpack
7
- * @property {string} id - The slug/ID of the modpack (Required)
8
- * @property {string} author - The author of the modpack (Required)
9
- * @property {string} projectUrl - The project URL of the modpack
10
- * @property {string} sourceUrl - The source code URL of the modpack
11
- * @property {string} license - The license of the modpack
12
- * @property {string} modloader - The modloader of the modpack (Required)
13
- * @property {string} targetModloaderVersion - The target modloader version of the modpack
14
- * @property {string} targetMinecraftVersion - The target Minecraft version of the modpack (Required)
15
- */
16
-
17
- /**
18
- * @typedef {Object} Lockfile
19
- * Contains information about the modpack dependencies and their versions.
20
- * @property {string} version - The version of the modpack
21
- * @property {string} generated - The date and time the lockfile was generated
22
- * @property {number} total - The total number of files in the modpack
23
- * @property {Object} counts - The counts object
24
- * @property {number} counts.mods - The mods count
25
- * @property {number} counts.resourcepacks - The resourcepacks count
26
- * @property {number} counts.datapacks - The datapacks count
27
- * @property {number} counts.shaderpacks - The shaderpacks count
28
- * @property {Object} dependencies - The dependencies object
29
- * @property {Array<Object>} dependencies.mods - The mods object
30
- * @property {Array<Object>} dependencies.resourcepacks - The resourcepacks object
31
- * @property {Array<Object>} dependencies.datapacks - The datapacks object
32
- * @property {Array<Object>} dependencies.shaderpacks - The shaderpacks object
33
- */
34
-
35
- /**
36
- * @typedef {Object} Options
37
- * Contains options for the generation of the modpack files.
38
- * @property {boolean} dryRun - Whether to dry run the generation
39
- * @property {boolean} quiet - Whether to quiet the console output
40
- * @property {boolean} silent - Whether to silent the console output
41
- * @property {boolean} gitignore - Whether to generate a .gitignore file
42
- * @property {boolean} readme - Whether to generate README.md files
43
- * @property {boolean} licenseFile - Whether to generate a license file
44
- */
45
-
46
- /**
47
- * @typedef {Object} InitOptions
48
- * Contains options for the initialization of the modpack files.
49
- * @property {string} folder - The folder to generate the modpack files in
50
- * @property {boolean} noninteractive - Whether to run the interactive mode
51
- * @property {boolean} addLicense - Whether to add the license file to the modpack
52
- * @property {boolean} addGitignore - Whether to generate .gitignore rules
53
- * @property {boolean} addReadme - Whether to generate README.md files
54
- * @property {string} name - The name of the modpack
55
- * @property {string} version - The version of the modpack
56
- * @property {string} id - The slug/ID of the modpack
57
- * @property {string} description - The description of the modpack
58
- * @property {string} author - The author of the modpack
59
- * @property {string} projectUrl - The modpack's project URL
60
- * @property {string} sourceUrl - The modpack's source code URL
61
- * @property {string} license - The modpack's license
62
- * @property {string} modloader - The modpack's modloader
63
- * @property {string} targetModloaderVersion - The target modloader version
64
- * @property {string} targetMinecraftVersion - The target Minecraft version
65
- * @property {boolean} _init - Internal boolean added to indicate options come from the `init` command.
66
- */
67
-
68
- /**
69
- * @typedef {Object} RunOptions
70
- * Contains options for the running scripts defined in modpack.json.
71
- * @property {string} folder - The folder to look for modpack.json in
72
- * @property {boolean} debug - Whether to print debug information about the executed script
73
- * @property {boolean} _run - Internal boolean added to indicate options come from the `run` command.
74
- */
75
-
76
- export {};
@@ -1,54 +0,0 @@
1
- import fs from "fs/promises";
2
- import path from "path";
3
- import {getLicenseText} from "./github_interactions.js";
4
- import * as config from "./config/index.js";
5
- import {logm} from "./logger.js";
6
-
7
- /**
8
- * @typedef {import('./config/types.js').ModpackInfo} ModpackInfo
9
- * @typedef {import('./config/types.js').Options} Options
10
- * @typedef {import('./config/types.js').InitOptions} InitOptions
11
- */
12
-
13
- async function writeLicense(licenseText, outputPath) {
14
- await fs.writeFile(path.join(outputPath, config.MODPACK_LICENSE_NAME), licenseText, "utf-8");
15
- logm.generated(config.MODPACK_LICENSE_NAME, path.join(outputPath, config.MODPACK_LICENSE_NAME));
16
- }
17
-
18
- /**
19
- * Write a license to a file
20
- * @param {ModpackInfo} modpackInfo - The modpack information
21
- * @param {string} workingDir - The path to write the license to
22
- * @param {InitOptions} options - The initialization options object
23
- * @param {string} licenseTextOverride - The license text to override the default license text with
24
- * @returns {Promise<string> | null} The license text or null if the license text could not be generated
25
- */
26
- export default async function generateLicense(modpackInfo, workingDir, options = {}, licenseTextOverride = null) {
27
- logm.quietFromOptions(options);
28
-
29
- try {
30
- const spdxId = modpackInfo.license;
31
-
32
- let licenseText = licenseTextOverride || (await getLicenseText(spdxId));
33
- licenseText = licenseText.replace("[year]", new Date().getFullYear());
34
- licenseText = licenseText.replace("{{year}}", new Date().getFullYear());
35
- licenseText = licenseText.replace("[fullname]", modpackInfo.author);
36
- licenseText = licenseText.replace("{{fullname}}", modpackInfo.author);
37
- licenseText = licenseText.replace("[organization]", modpackInfo.author);
38
- licenseText = licenseText.replace("{{organization}}", modpackInfo.author);
39
- licenseText = licenseText.replace("[project]", modpackInfo.name);
40
- licenseText = licenseText.replace("{{project}}", modpackInfo.name);
41
-
42
- if (options.dryRun) {
43
- logm.debug(
44
- config.dryRunText(config.MODPACK_LICENSE_NAME, path.join(workingDir, config.MODPACK_LICENSE_NAME)),
45
- );
46
- } else {
47
- await writeLicense(licenseText, workingDir);
48
- }
49
- return licenseText;
50
- } catch (error) {
51
- logm.warn(`Unable to generate license for: ${modpackInfo.license}`);
52
- return null;
53
- }
54
- }