modpack-lock 0.4.0 → 0.5.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 +82 -59
- package/package.json +1 -1
- package/src/cli.js +56 -27
- package/src/config/api.js +18 -0
- package/src/config/constants.js +18 -0
- package/src/config/defaults.js +58 -0
- package/src/config/files.js +9 -0
- package/src/config/index.js +1 -0
- package/src/config/options.js +15 -1
- package/src/config/strings.js +85 -0
- package/src/config/types.js +30 -0
- package/src/directory_scanning.js +4 -5
- package/src/generate_json.js +3 -3
- package/src/generate_license.js +50 -0
- package/src/generate_lockfile.js +100 -19
- package/src/github_interactions.js +73 -0
- package/src/modpack-lock.js +5 -3
- package/src/modpack_info.js +191 -111
- package/src/modrinth_interactions.js +57 -1
package/README.md
CHANGED
|
@@ -12,12 +12,10 @@ Creates a modpack lockfile for files hosted on Modrinth (mods, resource packs, s
|
|
|
12
12
|
|
|
13
13
|
Many mod and pack authors request that modpack creators link to Modrinth or CurseForge downloads rather than re-hosting files. This makes it difficult to track content files in version control when pushing to a remote server.
|
|
14
14
|
|
|
15
|
-
This script generates a `modpack.lock` file
|
|
15
|
+
This script generates a `modpack.lock` file containing a plaintext representation of the modpack's contents. This object contains the metadata for the content available on Modrinth, including hashes, versions, names, download URLs and more. An optional `modpack.json` file can also be created to store your modpack's metadata (name, version, modloader, dependencies, etc.) alongside the lockfile. This setup allows for easy diffing and clear version history.
|
|
16
16
|
|
|
17
17
|
> While an `.mrpack` file could be used to track changes to the modpack, it is a large, binary file that cannot be diffed and can contain large amounts of duplicate data from the rest of the repository.
|
|
18
18
|
|
|
19
|
-
The lockfile could also serve as a basis for restoring modpack contents after cloning the repository to a new machine.
|
|
20
|
-
|
|
21
19
|
Using the `scripts` field in `modpack.json`, you can also define reusable, tracked shell commands for common modpack tasks (like publishing, generating assets or CI/CD workflows).
|
|
22
20
|
|
|
23
21
|
## Installation
|
|
@@ -36,7 +34,7 @@ npx modpack-lock
|
|
|
36
34
|
|
|
37
35
|
## CLI
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
To generate a lockfile for your modpack, run:
|
|
40
38
|
|
|
41
39
|
```bash
|
|
42
40
|
modpack-lock
|
|
@@ -44,14 +42,12 @@ modpack-lock
|
|
|
44
42
|
|
|
45
43
|
The script will:
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
If a `modpack.json` file exists in the directory, the lockfile's dependency list will also be written to it. Run `modpack-lock init` to create this file.
|
|
45
|
+
- Scan target directory's `mods`, `resourcepacks`, `datapacks`, and `shaderpacks` directories for `.jar` and `.zip` files
|
|
46
|
+
- Calculate SHA1 hashes for each file
|
|
47
|
+
- Query the Modrinth API for matching versions
|
|
48
|
+
- Generate a `modpack.lock` file (and update `modpack.json` dependencies if present)
|
|
53
49
|
|
|
54
|
-
|
|
50
|
+
Use flags to generate `README.md` files for each category or update the `.gitignore` to ignore content hosted on Modrinth.
|
|
55
51
|
|
|
56
52
|
```text
|
|
57
53
|
Usage: modpack-lock [options] [command]
|
|
@@ -59,25 +55,31 @@ Usage: modpack-lock [options] [command]
|
|
|
59
55
|
Creates a modpack lockfile for files hosted on Modrinth (mods, resource packs, shaders and datapacks)
|
|
60
56
|
|
|
61
57
|
Options:
|
|
62
|
-
-p, --path <path>
|
|
63
|
-
-d, --dry-run
|
|
58
|
+
-p, --path <path> Path to the modpack directory
|
|
59
|
+
-d, --dry-run Dry-run mode - no files will be written
|
|
64
60
|
|
|
65
61
|
GENERATION
|
|
66
|
-
-g, --gitignore
|
|
67
|
-
-r, --readme
|
|
62
|
+
-g, --gitignore Update the .gitignore file to ignore content hosted on Modrinth
|
|
63
|
+
-r, --readme Generate README.md files for each category
|
|
68
64
|
|
|
69
65
|
LOGGING
|
|
70
|
-
-q, --quiet
|
|
71
|
-
-s, --silent
|
|
66
|
+
-q, --quiet Quiet mode - only show errors and warnings
|
|
67
|
+
-s, --silent Silent mode - no output
|
|
72
68
|
|
|
73
69
|
INFORMATION
|
|
74
|
-
-V
|
|
75
|
-
-h, --help
|
|
70
|
+
-V output the version number
|
|
71
|
+
-h, --help display help for modpack-lock
|
|
76
72
|
|
|
77
73
|
Commands:
|
|
78
|
-
init [options]
|
|
74
|
+
init [options] This utility will walk you through creating a modpack.json file. It only covers the most common items, and tries to guess sensible defaults.
|
|
75
|
+
run [options] <script> Run a script defined in the modpack.json file's 'scripts' field
|
|
79
76
|
```
|
|
80
77
|
|
|
78
|
+
> [!TIP]
|
|
79
|
+
>
|
|
80
|
+
> #### Did you know?
|
|
81
|
+
>
|
|
82
|
+
> You can generate summary files for each category by running `modpack-lock -r`. This will generate a `README.md` file in each of the content folders, detailing the scanned files and important attribution information for them.
|
|
81
83
|
|
|
82
84
|
### Initialization
|
|
83
85
|
|
|
@@ -87,9 +89,13 @@ To initialize a new modpack, run:
|
|
|
87
89
|
modpack-lock init
|
|
88
90
|
```
|
|
89
91
|
|
|
90
|
-
This
|
|
92
|
+
This command will:
|
|
93
|
+
|
|
94
|
+
- Prompt the user for the modpack's metadata (name, version, author, etc.)
|
|
95
|
+
- Generate the lockfile
|
|
96
|
+
- Generate a `modpack.json` file that stores your modpack's metadata (name, version, author, etc.), including a list of dependencies
|
|
91
97
|
|
|
92
|
-
The interactive mode will prompt you for each field. Set their initial values using the available option flags. Use `--noninteractive` with the required options
|
|
98
|
+
The interactive mode will prompt you for each field. Set their initial values using the available option flags. Use `--noninteractive` with the required options to skip the interactive-prompt and use the provided values.
|
|
93
99
|
|
|
94
100
|
```text
|
|
95
101
|
Usage: modpack-lock init [options]
|
|
@@ -99,46 +105,53 @@ This utility will walk you through creating a modpack.json file. It only covers
|
|
|
99
105
|
Options:
|
|
100
106
|
-f, --folder <path> Path to the modpack directory
|
|
101
107
|
-n, --noninteractive Non-interactive mode - must provide options for required fields
|
|
108
|
+
--add-license Add the LICENSE file to the modpack
|
|
109
|
+
--add-gitignore Update the .gitignore file to ignore content hosted on Modrinth
|
|
110
|
+
--add-readme Generate README.md files for each category
|
|
102
111
|
|
|
103
112
|
MODPACK INFORMATION
|
|
104
|
-
--name <name> Modpack name; defaults to the directory name
|
|
105
|
-
--version <version> Modpack version; defaults to 1.0.0
|
|
106
|
-
--id <id> Modpack slug/ID; defaults to the directory name slugified
|
|
113
|
+
--name <name> Modpack name; defaults to the directory name
|
|
114
|
+
--version <version> Modpack version; defaults to 1.0.0
|
|
115
|
+
--id <id> Modpack slug/ID; defaults to the directory name slugified
|
|
107
116
|
--description <description> Modpack description
|
|
108
117
|
--author <author> Modpack author; required
|
|
109
|
-
--projectUrl <projectUrl> Modpack URL
|
|
110
|
-
--sourceUrl <sourceUrl> Modpack source code URL
|
|
111
|
-
--license <license> Modpack license
|
|
112
|
-
--modloader <modloader> Modpack modloader; required
|
|
118
|
+
--projectUrl <projectUrl> Modpack URL; defaults to a guessed Modrinth project URL
|
|
119
|
+
--sourceUrl <sourceUrl> Modpack source code URL; defaults to a guessed GitHub repository URL
|
|
120
|
+
--license <license> Modpack license, popular licenses fetched from GitHub; defaults to MIT in interactive mode
|
|
121
|
+
--modloader <modloader> Modpack modloader, list of loaders fetched from Modrinth; required
|
|
113
122
|
--targetModloaderVersion <targetModloaderVersion> Target modloader version
|
|
114
|
-
--targetMinecraftVersion <targetMinecraftVersion> Target Minecraft version; required
|
|
123
|
+
--targetMinecraftVersion <targetMinecraftVersion> Target Minecraft version, list of versions fetched from Modrinth; required
|
|
115
124
|
|
|
116
125
|
INFORMATION
|
|
117
|
-
--help
|
|
126
|
+
-h, --help display help for modpack-lock init
|
|
118
127
|
```
|
|
119
128
|
|
|
120
129
|
### Running Scripts
|
|
121
130
|
|
|
122
|
-
To run a script defined in `modpack.json
|
|
131
|
+
To run a script defined in `modpack.json`, run:
|
|
123
132
|
|
|
124
133
|
```bash
|
|
125
134
|
modpack-lock run <script>
|
|
126
135
|
```
|
|
127
136
|
|
|
128
|
-
This command takes the name of the script as its first argument
|
|
137
|
+
This command takes the name of the script as its first argument:
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
- It searches for a scripts fiels in `modpack.json` in the current directory by default.
|
|
140
|
+
- Use the `-f` option to specify a different path to the modpack directory.
|
|
141
|
+
- For debug logging, use the `-D` option.
|
|
131
142
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
```
|
|
143
|
+
> To pass additional arguments and options to the script, write them after a `--` separator:
|
|
144
|
+
>
|
|
145
|
+
> ```bash
|
|
146
|
+
> modpack-lock run <script> -- [options] <args>
|
|
147
|
+
> ```
|
|
135
148
|
|
|
136
149
|
The `scripts` field in `modpack.json` is a key-value pair of script names and their corresponding shell commands. The `scripts` field is optional and is omitted by default.
|
|
137
150
|
|
|
138
151
|
```text
|
|
139
152
|
Usage: modpack-lock run [options] <script>
|
|
140
153
|
|
|
141
|
-
Run a script
|
|
154
|
+
Run a script defined in the modpack.json file's 'scripts' field
|
|
142
155
|
|
|
143
156
|
Arguments:
|
|
144
157
|
script The name of the script to run
|
|
@@ -146,25 +159,11 @@ Arguments:
|
|
|
146
159
|
Options:
|
|
147
160
|
-f, --folder <path> Path to the modpack directory
|
|
148
161
|
-D, --debug Debug mode -- show more information about how the command is being parsed
|
|
162
|
+
|
|
163
|
+
INFORMATION
|
|
149
164
|
-h, --help display help for modpack-lock run
|
|
150
165
|
```
|
|
151
166
|
|
|
152
|
-
> [!TIP]
|
|
153
|
-
>
|
|
154
|
-
> You can run this script as a pre-commit hook to ensure that the modpack lockfile is up to date before committing your changes to your repository.
|
|
155
|
-
>
|
|
156
|
-
> Also, consider adding these rules to your `.gitignore` to ensure you don't commit the modpack contents to your repository, with exceptions for any files that are not Modrinth-hosted:
|
|
157
|
-
>
|
|
158
|
-
> ```txt
|
|
159
|
-
> mods/*.jar
|
|
160
|
-
> resourcepacks/*.zip
|
|
161
|
-
> datapacks/*.zip
|
|
162
|
-
> shaderpacks/*.zip
|
|
163
|
-
>
|
|
164
|
-
> ## Exceptions
|
|
165
|
-
> # !mods/example.jar
|
|
166
|
-
> ```
|
|
167
|
-
|
|
168
167
|
## API
|
|
169
168
|
|
|
170
169
|
For programmatic usage, `modpack-lock` exports these functions:
|
|
@@ -174,6 +173,7 @@ For programmatic usage, `modpack-lock` exports these functions:
|
|
|
174
173
|
- `generateJson()`
|
|
175
174
|
- `generateGitignoreRules()`
|
|
176
175
|
- `generateReadmeFiles()`
|
|
176
|
+
- `generateLicense()`
|
|
177
177
|
- `generateLockfile()`
|
|
178
178
|
- `generateModpackFiles()`
|
|
179
179
|
- `promptUserForInfo()`
|
|
@@ -184,7 +184,7 @@ See the [API documentation](https://nickesc.github.io/modpack-lock) for full det
|
|
|
184
184
|
|
|
185
185
|
### `modpack.lock`
|
|
186
186
|
|
|
187
|
-
The lockfile contains metadata about Modrinth-hosted files found in
|
|
187
|
+
The lockfile contains metadata about Modrinth-hosted files found in modpack directories:
|
|
188
188
|
|
|
189
189
|
```json
|
|
190
190
|
{
|
|
@@ -213,7 +213,7 @@ The lockfile contains metadata about Modrinth-hosted files found in your modpack
|
|
|
213
213
|
|
|
214
214
|
### `modpack.json`
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
The JSON file contains your modpack metadata and a dependency list:
|
|
217
217
|
|
|
218
218
|
```json
|
|
219
219
|
{
|
|
@@ -228,18 +228,41 @@ If created via `modpack-lock init`, the JSON file combines your modpack metadata
|
|
|
228
228
|
"modloader": "modloader",
|
|
229
229
|
"targetModloaderVersion": "",
|
|
230
230
|
"targetMinecraftVersion": "x.y.z",
|
|
231
|
+
"scripts": {
|
|
232
|
+
"example": "echo 'example script'"
|
|
233
|
+
},
|
|
231
234
|
"dependencies": {
|
|
232
235
|
"mods": [ ... ],
|
|
233
236
|
"resourcepacks": [ ... ],
|
|
234
237
|
"datapacks": [ ... ],
|
|
235
238
|
"shaderpacks": [ ... ]
|
|
236
|
-
},
|
|
237
|
-
"scripts": {
|
|
238
|
-
"example": "echo 'example script'"
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
+
> [!IMPORTANT]
|
|
244
|
+
>
|
|
245
|
+
> #### Don't commit binaries
|
|
246
|
+
>
|
|
247
|
+
> Use `modpack-lock -g` to automatically update your `.gitignore` file with rules to ignore modpack contents, with exceptions for any files that are not hosted by Modrinth:
|
|
248
|
+
>
|
|
249
|
+
> ```txt
|
|
250
|
+
> # .gitignore
|
|
251
|
+
>
|
|
252
|
+
> # modpack-lock:start
|
|
253
|
+
> mods/*.jar
|
|
254
|
+
> resourcepacks/*.zip
|
|
255
|
+
> datapacks/*.zip
|
|
256
|
+
> shaderpacks/*.zip
|
|
257
|
+
> */**/*.disabled
|
|
258
|
+
>
|
|
259
|
+
> ## Exceptions
|
|
260
|
+
> !mods/example.jar
|
|
261
|
+
> # modpack-lock:end
|
|
262
|
+
> ```
|
|
263
|
+
>
|
|
264
|
+
> This section is managed by modpack-lock and will be updated automatically when you run `modpack-lock -g`. Changes made inside this section will be overwritten, but any changes you make outside of this section will be preserved.
|
|
265
|
+
|
|
243
266
|
## License
|
|
244
267
|
|
|
245
268
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for more details.
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -6,8 +6,9 @@ import path from 'path';
|
|
|
6
6
|
import { spawn } from 'child_process';
|
|
7
7
|
import {generateLockfile} from './generate_lockfile.js';
|
|
8
8
|
import { generateModpackFiles } from './modpack-lock.js';
|
|
9
|
-
import promptUserForInfo from './modpack_info.js';
|
|
9
|
+
import { promptUserForInfo, promptUserAboutOptionalFiles } from './modpack_info.js';
|
|
10
10
|
import { getModpackInfo } from './directory_scanning.js';
|
|
11
|
+
import generateLicense from './generate_license.js';
|
|
11
12
|
import * as config from './config/index.js';
|
|
12
13
|
import pkg from '../package.json' with { type: 'json' };
|
|
13
14
|
|
|
@@ -69,16 +70,16 @@ modpackLock
|
|
|
69
70
|
.name(pkg.name)
|
|
70
71
|
.description(pkg.description)
|
|
71
72
|
.summary("Create a modpack lockfile")
|
|
72
|
-
.optionsGroup(
|
|
73
|
+
.optionsGroup(config.headings.options)
|
|
73
74
|
.option('-p, --path <path>', 'Path to the modpack directory')
|
|
74
75
|
.option('-d, --dry-run', 'Dry-run mode - no files will be written')
|
|
75
|
-
.optionsGroup(
|
|
76
|
-
.option('-g, --gitignore',
|
|
77
|
-
.option('-r, --readme',
|
|
78
|
-
.optionsGroup(
|
|
76
|
+
.optionsGroup(config.headings.generation)
|
|
77
|
+
.option('-g, --gitignore', config.fileFields.addGitignore.option)
|
|
78
|
+
.option('-r, --readme', config.fileFields.addReadme.option)
|
|
79
|
+
.optionsGroup(config.headings.logging)
|
|
79
80
|
.option('-q, --quiet', 'Quiet mode - only show errors and warnings')
|
|
80
81
|
.option('-s, --silent', 'Silent mode - no output')
|
|
81
|
-
.optionsGroup(
|
|
82
|
+
.optionsGroup(config.headings.information)
|
|
82
83
|
.helpOption("-h, --help", `display help for ${pkg.name}`)
|
|
83
84
|
.version(pkg.version, '-V')
|
|
84
85
|
.action(async (options) => {
|
|
@@ -107,24 +108,28 @@ const jsonDescription = `This utility will walk you through creating a ${config.
|
|
|
107
108
|
|
|
108
109
|
modpackLock.command('init')
|
|
109
110
|
.description(jsonDescription)
|
|
110
|
-
.optionsGroup(
|
|
111
|
+
.optionsGroup(config.headings.options)
|
|
111
112
|
.option('-f, --folder <path>', 'Path to the modpack directory')
|
|
112
113
|
.option("-n, --noninteractive", 'Non-interactive mode - must provide options for required fields')
|
|
113
|
-
.
|
|
114
|
-
.option('--
|
|
115
|
-
.option('--
|
|
116
|
-
.
|
|
117
|
-
.option('--
|
|
118
|
-
.option('--
|
|
119
|
-
.option('--
|
|
120
|
-
.option('--
|
|
121
|
-
.option('--
|
|
122
|
-
.option('--
|
|
123
|
-
.option('--
|
|
124
|
-
.option('--
|
|
125
|
-
.
|
|
114
|
+
.option('--add-license', config.fileFields.addLicense.option)
|
|
115
|
+
.option('--add-gitignore', config.fileFields.addGitignore.option)
|
|
116
|
+
.option('--add-readme', config.fileFields.addReadme.option)
|
|
117
|
+
.optionsGroup(config.headings.packInfo)
|
|
118
|
+
.option('--name <name>', config.infoFields.name.option)
|
|
119
|
+
.option('--version <version>', config.infoFields.version.option)
|
|
120
|
+
.option('--id <id>', config.infoFields.id.option)
|
|
121
|
+
.option('--description <description>', config.infoFields.description.option)
|
|
122
|
+
.option('--author <author>', config.infoFields.author.option)
|
|
123
|
+
.option('--projectUrl <projectUrl>', config.infoFields.projectUrl.option)
|
|
124
|
+
.option('--sourceUrl <sourceUrl>', config.infoFields.sourceUrl.option)
|
|
125
|
+
.option('--license <license>', config.infoFields.license.option)
|
|
126
|
+
.option('--modloader <modloader>', config.infoFields.modloader.option)
|
|
127
|
+
.option('--targetModloaderVersion <targetModloaderVersion>', config.infoFields.targetModloaderVersion.option)
|
|
128
|
+
.option('--targetMinecraftVersion <targetMinecraftVersion>', config.infoFields.targetMinecraftVersion.option)
|
|
129
|
+
.optionsGroup(config.headings.information)
|
|
126
130
|
.helpOption("-h, --help", `display help for ${pkg.name} init`)
|
|
127
131
|
.action(async (options) => {
|
|
132
|
+
options._init = true;
|
|
128
133
|
const currDir = options.folder || process.cwd();
|
|
129
134
|
|
|
130
135
|
let existingInfo = await getModpackInfo(currDir);
|
|
@@ -153,8 +158,17 @@ modpackLock.command('init')
|
|
|
153
158
|
|
|
154
159
|
const modpackInfo = mergeModpackInfo(existingInfo, options, defaults);
|
|
155
160
|
modpackInfo.id = slugify(modpackInfo.id, config.SLUGIFY_OPTIONS);
|
|
161
|
+
|
|
162
|
+
if (options.addLicense) {
|
|
163
|
+
await generateLicense(modpackInfo, currDir, options);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
options.readme = options.addReadme;
|
|
167
|
+
options.gitignore = options.addGitignore;
|
|
168
|
+
|
|
169
|
+
// generate the modpack files
|
|
156
170
|
try {
|
|
157
|
-
await generateModpackFiles(modpackInfo, currDir,
|
|
171
|
+
await generateModpackFiles(modpackInfo, currDir, options);
|
|
158
172
|
} catch (error) {
|
|
159
173
|
console.error('Error:', error);
|
|
160
174
|
process.exitCode = 1;
|
|
@@ -179,11 +193,23 @@ modpackLock.command('init')
|
|
|
179
193
|
targetMinecraftVersion: undefined,
|
|
180
194
|
};
|
|
181
195
|
|
|
196
|
+
// prompt user for modpack information
|
|
182
197
|
const modpackInfo = await promptUserForInfo(
|
|
183
198
|
mergeModpackInfo(existingInfo, options, defaults)
|
|
184
199
|
);
|
|
185
200
|
|
|
186
|
-
|
|
201
|
+
// prompt user if they want to add the license text
|
|
202
|
+
const optionalFiles = await promptUserAboutOptionalFiles(modpackInfo, options);
|
|
203
|
+
console.log();
|
|
204
|
+
if (options.addLicense || optionalFiles.addLicense) {
|
|
205
|
+
await generateLicense(modpackInfo, currDir, options);
|
|
206
|
+
}
|
|
207
|
+
console.log();
|
|
208
|
+
|
|
209
|
+
// generate the modpack files
|
|
210
|
+
options.readme = optionalFiles.addReadme;
|
|
211
|
+
options.gitignore = optionalFiles.addGitignore;
|
|
212
|
+
await generateModpackFiles(modpackInfo, currDir, options);
|
|
187
213
|
} catch (error) {
|
|
188
214
|
console.error('Error:', error);
|
|
189
215
|
process.exitCode = 1;
|
|
@@ -192,14 +218,17 @@ modpackLock.command('init')
|
|
|
192
218
|
});
|
|
193
219
|
|
|
194
220
|
modpackLock.command('run')
|
|
195
|
-
.description(`Run a script
|
|
221
|
+
.description(`Run a script defined in the ${config.MODPACK_JSON_NAME} file's 'scripts' field`)
|
|
196
222
|
.argument('<script>', 'The name of the script to run')
|
|
223
|
+
.optionsGroup(config.headings.options)
|
|
197
224
|
.option('-f, --folder <path>', 'Path to the modpack directory')
|
|
198
225
|
.option('-D, --debug', 'Debug mode -- show more information about how the command is being parsed')
|
|
226
|
+
.optionsGroup(config.headings.information)
|
|
199
227
|
.helpOption("-h, --help", `display help for ${pkg.name} run`)
|
|
200
228
|
.allowExcessArguments(true)
|
|
201
229
|
.allowUnknownOption(true)
|
|
202
230
|
.action(async (script, options, command) => {
|
|
231
|
+
options._run = true;
|
|
203
232
|
try {
|
|
204
233
|
if (options.debug) {
|
|
205
234
|
console.log("COMMAND:", command);
|
|
@@ -210,13 +239,13 @@ modpackLock.command('run')
|
|
|
210
239
|
|
|
211
240
|
// verify neccecary files and information exist
|
|
212
241
|
if (!modpackInfo) {
|
|
213
|
-
throw new Error(
|
|
242
|
+
throw new Error(`No ${config.MODPACK_JSON_NAME} file found`);
|
|
214
243
|
}
|
|
215
244
|
if (!modpackInfo.scripts) {
|
|
216
|
-
throw new Error(
|
|
245
|
+
throw new Error(`No scripts defined in ${config.MODPACK_JSON_NAME}`);
|
|
217
246
|
}
|
|
218
247
|
if (!modpackInfo.scripts[script]) {
|
|
219
|
-
throw new Error(`Script ${script} not found in
|
|
248
|
+
throw new Error(`Script ${script} not found in ${config.MODPACK_JSON_NAME}`);
|
|
220
249
|
}
|
|
221
250
|
|
|
222
251
|
// build the full command
|
package/src/config/api.js
CHANGED
|
@@ -10,5 +10,23 @@ export const MODRINTH_PROJECTS_ENDPOINT = `${MODRINTH_API_BASE}/projects`;
|
|
|
10
10
|
/** Modrinth users endpoint */
|
|
11
11
|
export const MODRINTH_USERS_ENDPOINT = `${MODRINTH_API_BASE}/users`;
|
|
12
12
|
|
|
13
|
+
/** Modrinth Minecraft versions endpoint */
|
|
14
|
+
export const MODRINTH_MINECRAFT_VERSIONS_ENDPOINT = `${MODRINTH_API_BASE}/tag/game_version`;
|
|
15
|
+
|
|
16
|
+
/** Modrinth Modloaders endpoint */
|
|
17
|
+
export const MODRINTH_MODLOADERS_ENDPOINT = `${MODRINTH_API_BASE}/tag/loader`;
|
|
18
|
+
|
|
13
19
|
/** Batch size for Modrinth API requests */
|
|
14
20
|
export const BATCH_SIZE = 100;
|
|
21
|
+
|
|
22
|
+
/** GitHub API base URL */
|
|
23
|
+
export const GITHUB_API_BASE = 'https://api.github.com';
|
|
24
|
+
|
|
25
|
+
/** GitHub licenses endpoint */
|
|
26
|
+
export const GITHUB_LICENSES_ENDPOINT = `${GITHUB_API_BASE}/licenses`;
|
|
27
|
+
|
|
28
|
+
/** GitHub featured licenses endpoint */
|
|
29
|
+
export const GITHUB_FEATURED_LICENSES_ENDPOINT = `${GITHUB_LICENSES_ENDPOINT}?featured=true`;
|
|
30
|
+
|
|
31
|
+
/** GitHub license endpoint */
|
|
32
|
+
export const GITHUB_LICENSE_ENDPOINT = (license) => `${GITHUB_API_BASE}/licenses/${license}`;
|
package/src/config/constants.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pkg from '../../package.json' with { type: 'json' };
|
|
2
|
+
|
|
1
3
|
/** Lockfile format version -- increment on changes to the format */
|
|
2
4
|
export const LOCKFILE_VERSION = "1.0.1";
|
|
3
5
|
|
|
@@ -18,3 +20,19 @@ export const DEPENDENCY_CATEGORIES = [
|
|
|
18
20
|
"shaderpacks",
|
|
19
21
|
"datapacks"
|
|
20
22
|
];
|
|
23
|
+
|
|
24
|
+
/** Minecraft version types */
|
|
25
|
+
export const MINECRAFT_VERSION_TYPES = [
|
|
26
|
+
"release",
|
|
27
|
+
"alpha",
|
|
28
|
+
"beta",
|
|
29
|
+
"snapshot"
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const gitignoreMarker = (mode) => `# ${pkg.name}:${mode}`;
|
|
33
|
+
|
|
34
|
+
/** Gitignore section start marker */
|
|
35
|
+
export const GITIGNORE_START_MARKER = gitignoreMarker('start');
|
|
36
|
+
|
|
37
|
+
/** Gitignore section end marker */
|
|
38
|
+
export const GITIGNORE_END_MARKER = gitignoreMarker('end');
|
package/src/config/defaults.js
CHANGED
|
@@ -1,8 +1,66 @@
|
|
|
1
1
|
export const DEFAULT_MODPACK_VERSION = '1.0.0';
|
|
2
|
+
|
|
2
3
|
export const DEFAULT_MODPACK_LICENSE = 'MIT';
|
|
4
|
+
|
|
3
5
|
export const DEFAULT_PROJECT_URL = (id) => {
|
|
4
6
|
return `https://modrinth.com/modpack/${id}`;
|
|
5
7
|
};
|
|
6
8
|
export const DEFAULT_SOURCE_URL = (id, author) => {
|
|
7
9
|
return `https://github.com/${author}/${id}`;
|
|
8
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
|
+
];
|
package/src/config/files.js
CHANGED
|
@@ -3,3 +3,12 @@ export const MODPACK_LOCKFILE_NAME = "modpack.lock";
|
|
|
3
3
|
|
|
4
4
|
/** Human-readable/JSON file name */
|
|
5
5
|
export const MODPACK_JSON_NAME = "modpack.json";
|
|
6
|
+
|
|
7
|
+
/** License file name */
|
|
8
|
+
export const MODPACK_LICENSE_NAME = "LICENSE";
|
|
9
|
+
|
|
10
|
+
/** Gitignore file name */
|
|
11
|
+
export const GITIGNORE_NAME = ".gitignore";
|
|
12
|
+
|
|
13
|
+
/** README.md file name */
|
|
14
|
+
export const README_NAME = "README.md";
|
package/src/config/index.js
CHANGED
package/src/config/options.js
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
/** Options for slugify */
|
|
2
|
-
export const SLUGIFY_OPTIONS = {
|
|
2
|
+
export const SLUGIFY_OPTIONS = {
|
|
3
|
+
lower: true,
|
|
4
|
+
strict: true,
|
|
5
|
+
separator: '-',
|
|
6
|
+
locale: 'en',
|
|
7
|
+
trim: true
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** Options for prompts */
|
|
11
|
+
export const PROMPTS_OPTIONS = {
|
|
12
|
+
onCancel: () => {
|
|
13
|
+
console.warn('Modpack initialization was interrupted');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
};
|