modpack-lock 0.6.2 → 0.8.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 +24 -18
- 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 +29 -0
- package/build/config/api.d.ts.map +1 -0
- package/{src → build}/config/api.js +4 -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 +18 -0
- package/build/generate_json.d.ts.map +1 -0
- package/build/generate_json.js +137 -0
- 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/build/modpack-lock.js +43 -0
- 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 +72 -55
- package/build/modrinth_interactions.js.map +1 -0
- package/build/types/Jsonfile.d.ts +26 -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_json.js +0 -106
- package/src/generate_license.js +0 -54
- package/src/modpack-lock.js +0 -69
- package/src/modpack_info.js +0 -200
package/{src → build}/logger.js
RENAMED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {styleText} from "node:util";
|
|
2
|
-
|
|
1
|
+
import { styleText } from "node:util";
|
|
3
2
|
class Logger {
|
|
4
3
|
/**
|
|
5
4
|
* The styles to apply to the console output.
|
|
6
|
-
* @type {Object}
|
|
7
5
|
*/
|
|
8
6
|
styles = {
|
|
9
|
-
log:
|
|
10
|
-
info:
|
|
7
|
+
log: [],
|
|
8
|
+
info: [],
|
|
11
9
|
debug: ["magenta"],
|
|
12
10
|
warn: ["yellow"],
|
|
13
11
|
error: ["red"],
|
|
@@ -18,25 +16,36 @@ class Logger {
|
|
|
18
16
|
labelError: ["red", "inverse", "bold"],
|
|
19
17
|
labelGenerated: ["green", "inverse", "bold"],
|
|
20
18
|
};
|
|
21
|
-
|
|
22
19
|
quietConsole = false;
|
|
23
20
|
silentConsole = false;
|
|
24
21
|
lastLogWasNewline = false;
|
|
25
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Set the quiet console flag. When set, only errors and warnings are logged to the console.
|
|
24
|
+
* @param silent - Whether to also set the silent console flag. When set, no console output is logged.
|
|
25
|
+
*/
|
|
26
26
|
quiet(silent = false) {
|
|
27
27
|
this.quietConsole = true;
|
|
28
28
|
this.silentConsole = silent;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Set the quiet console flag based on the options object.
|
|
32
|
+
* @param options - The options object containing the quiet and silent flags.
|
|
33
|
+
*/
|
|
31
34
|
quietFromOptions(options) {
|
|
32
35
|
if (options.silent) {
|
|
33
36
|
this.quietConsole = true;
|
|
34
37
|
this.silentConsole = true;
|
|
35
|
-
}
|
|
38
|
+
}
|
|
39
|
+
else if (options.quiet) {
|
|
36
40
|
this.quietConsole = true;
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Style the arguments with the given style.
|
|
45
|
+
* @param style - The style to apply to the arguments.
|
|
46
|
+
* @param args - The arguments to style.
|
|
47
|
+
* @returns The styled arguments.
|
|
48
|
+
*/
|
|
40
49
|
styleArgs(style, args) {
|
|
41
50
|
if (!style) {
|
|
42
51
|
return args;
|
|
@@ -46,20 +55,18 @@ class Logger {
|
|
|
46
55
|
}
|
|
47
56
|
return args.map((arg) => (typeof arg === "string" ? styleText(style, arg) : arg));
|
|
48
57
|
}
|
|
49
|
-
|
|
50
58
|
/**
|
|
51
59
|
* Style the text as a label.
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @returns
|
|
60
|
+
* @param text - The text to style.
|
|
61
|
+
* @param style - The style to apply to the text.
|
|
62
|
+
* @returns The styled text.
|
|
55
63
|
*/
|
|
56
64
|
label(text, style = this.styles.label) {
|
|
57
65
|
return styleText(style, String(text).toUpperCase());
|
|
58
66
|
}
|
|
59
|
-
|
|
60
67
|
/**
|
|
61
68
|
* Log a header.
|
|
62
|
-
* @param
|
|
69
|
+
* @param text - The text to log.
|
|
63
70
|
*/
|
|
64
71
|
header(text) {
|
|
65
72
|
if (this.quietConsole) {
|
|
@@ -72,21 +79,21 @@ class Logger {
|
|
|
72
79
|
console.info();
|
|
73
80
|
this.lastLogWasNewline = true;
|
|
74
81
|
}
|
|
75
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Log a message indicating that a file was generated.
|
|
84
|
+
* @param desc - The description of the file that was generated.
|
|
85
|
+
* @param outputPath - The path to the file that was generated.
|
|
86
|
+
*/
|
|
76
87
|
generated(desc, outputPath) {
|
|
77
88
|
if (this.quietConsole) {
|
|
78
89
|
return;
|
|
79
90
|
}
|
|
80
|
-
console.log(
|
|
81
|
-
this.label("Generated", this.styles.labelGenerated),
|
|
82
|
-
styleText(this.styles.generated, "Wrote"),
|
|
83
|
-
styleText(this.styles.generated, desc),
|
|
84
|
-
styleText(this.styles.generated, "to:"),
|
|
85
|
-
styleText(["dim"], `${outputPath}`),
|
|
86
|
-
);
|
|
91
|
+
console.log(this.label("Generated", this.styles.labelGenerated), styleText(this.styles.generated, "Wrote"), styleText(this.styles.generated, desc), styleText(this.styles.generated, "to:"), styleText(["dim"], `${outputPath}`));
|
|
87
92
|
this.lastLogWasNewline = false;
|
|
88
93
|
}
|
|
89
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Log a newline. Only logs a newline if the last log was not a newline.
|
|
96
|
+
*/
|
|
90
97
|
newline() {
|
|
91
98
|
if (this.quietConsole) {
|
|
92
99
|
return;
|
|
@@ -97,11 +104,10 @@ class Logger {
|
|
|
97
104
|
console.info();
|
|
98
105
|
this.lastLogWasNewline = true;
|
|
99
106
|
}
|
|
100
|
-
|
|
101
107
|
/**
|
|
102
108
|
* Log a message.
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
109
|
+
* @param message - The message to log.
|
|
110
|
+
* @param otherMessages - Other messages to log.
|
|
105
111
|
*/
|
|
106
112
|
log(message, ...otherMessages) {
|
|
107
113
|
if (this.quietConsole) {
|
|
@@ -110,11 +116,10 @@ class Logger {
|
|
|
110
116
|
console.log(...this.styleArgs(this.styles.log, [message, ...otherMessages]));
|
|
111
117
|
this.lastLogWasNewline = false;
|
|
112
118
|
}
|
|
113
|
-
|
|
114
119
|
/**
|
|
115
120
|
* Log an info message.
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
121
|
+
* @param message - The message to log.
|
|
122
|
+
* @param otherMessages - Other messages to log.
|
|
118
123
|
*/
|
|
119
124
|
info(message, ...otherMessages) {
|
|
120
125
|
if (this.quietConsole) {
|
|
@@ -123,56 +128,43 @@ class Logger {
|
|
|
123
128
|
console.info(...this.styleArgs(this.styles.info, [message, ...otherMessages]));
|
|
124
129
|
this.lastLogWasNewline = false;
|
|
125
130
|
}
|
|
126
|
-
|
|
127
131
|
/**
|
|
128
132
|
* Log a debug message.
|
|
129
|
-
* @param
|
|
130
|
-
* @param
|
|
133
|
+
* @param message - The message to log.
|
|
134
|
+
* @param otherMessages - Other messages to log.
|
|
131
135
|
*/
|
|
132
136
|
debug(message, ...otherMessages) {
|
|
133
137
|
if (this.silentConsole) {
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
136
|
-
console.debug(
|
|
137
|
-
this.label("//", this.styles.labelDebug),
|
|
138
|
-
...this.styleArgs(this.styles.debug, [message, ...otherMessages]),
|
|
139
|
-
);
|
|
140
|
+
console.debug(this.label("//", this.styles.labelDebug), ...this.styleArgs(this.styles.debug, [message, ...otherMessages]));
|
|
140
141
|
this.lastLogWasNewline = false;
|
|
141
142
|
}
|
|
142
|
-
|
|
143
143
|
/**
|
|
144
144
|
* Log a warning message.
|
|
145
|
-
* @param
|
|
146
|
-
* @param
|
|
145
|
+
* @param message - The message to log.
|
|
146
|
+
* @param otherMessages - Other messages to log.
|
|
147
147
|
*/
|
|
148
148
|
warn(message, ...otherMessages) {
|
|
149
149
|
if (this.silentConsole) {
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
|
-
console.warn(
|
|
153
|
-
this.label("WARNING", this.styles.labelWarn),
|
|
154
|
-
...this.styleArgs(this.styles.warn, [message, ...otherMessages]),
|
|
155
|
-
);
|
|
152
|
+
console.warn(this.label("WARNING", this.styles.labelWarn), ...this.styleArgs(this.styles.warn, [message, ...otherMessages]));
|
|
156
153
|
this.lastLogWasNewline = false;
|
|
157
154
|
}
|
|
158
|
-
|
|
159
155
|
/**
|
|
160
156
|
* Log an error message.
|
|
161
|
-
* @param
|
|
162
|
-
* @param
|
|
157
|
+
* @param message - The message to log.
|
|
158
|
+
* @param otherMessages - Other messages to log.
|
|
163
159
|
*/
|
|
164
160
|
error(message, ...otherMessages) {
|
|
165
161
|
if (this.silentConsole) {
|
|
166
162
|
return;
|
|
167
163
|
}
|
|
168
|
-
console.error(
|
|
169
|
-
this.label("ERROR", this.styles.labelError),
|
|
170
|
-
...this.styleArgs(this.styles.error, [message, ...otherMessages]),
|
|
171
|
-
);
|
|
164
|
+
console.error(this.label("ERROR", this.styles.labelError), ...this.styleArgs(this.styles.error, [message, ...otherMessages]));
|
|
172
165
|
this.lastLogWasNewline = false;
|
|
173
166
|
}
|
|
174
167
|
}
|
|
175
|
-
|
|
176
168
|
const logm = new Logger();
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
export { logm, styleText };
|
|
170
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAIpC,MAAM,MAAM;IACR;;OAEG;IACH,MAAM,GAYF;QACA,GAAG,EAAE,EAAE;QACP,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,CAAC,SAAS,CAAC;QAClB,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,KAAK,EAAE,CAAC,KAAK,CAAC;QACd,SAAS,EAAE,CAAC,OAAO,C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,GAAG,aAAoB;QACtC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO;QACX,CAAC;QACD,OAAO,CAAC,IAAI,CACR,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAC5C,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,CAAC,CACnE,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAY,EAAE,GAAG,aAAoB;QACvC,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO;QACX,CAAC;QACD,OAAO,CAAC,KAAK,CACT,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAC3C,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,CAAC,CACpE,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACnC,CAAC;CACJ;AAED,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;AAE1B,OAAO,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { generateLockfile } from "./generate_lockfile.js";
|
|
2
|
+
import { generateReadmeFiles } from "./generate_readme.js";
|
|
3
|
+
import { generateGitignoreRules } from "./generate_gitignore.js";
|
|
4
|
+
import { generateJson, normalizeDependencies } from "./generate_json.js";
|
|
5
|
+
import generateLicense from "./generate_license.js";
|
|
6
|
+
import { promptUserForInfo } from "./user_prompts.js";
|
|
7
|
+
import { getModpackInfo, getLockfile } from "./directory_scanning.js";
|
|
8
|
+
import type { Jsonfile, DependencyMap, Options, InitOptions, Lockfile, ModpackInfo, DependencyCategory, LockfileDependency, ContentVersion, VersionDependency } from "./types/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* @license MIT
|
|
11
|
+
* @author nickesc
|
|
12
|
+
* @module modpack-lock
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Generate the modpack files (lockfile, JSON, and optionally license, gitignore, and readme)
|
|
16
|
+
* @param modpackInfo - The Jsonfile object containing the modpack information
|
|
17
|
+
* @param workingDir - The directory to generate the files in
|
|
18
|
+
* @param options - The options object
|
|
19
|
+
* @returns The lockfile object
|
|
20
|
+
*/
|
|
21
|
+
declare function generateModpackFiles(modpackInfo: Jsonfile, workingDir: string, options?: Options | InitOptions): Promise<Lockfile>;
|
|
22
|
+
export { generateModpackFiles, generateJson, normalizeDependencies, generateLockfile, generateGitignoreRules, generateReadmeFiles, generateLicense, getModpackInfo, getLockfile, promptUserForInfo, };
|
|
23
|
+
export type { Lockfile, //
|
|
24
|
+
ModpackInfo, Jsonfile, DependencyMap, Options, InitOptions, DependencyCategory, LockfileDependency, ContentVersion, VersionDependency, };
|
|
25
|
+
//# sourceMappingURL=modpack-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modpack-lock.d.ts","sourceRoot":"","sources":["../src/modpack-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACR,QAAQ,EACR,aAAa,EACb,OAAO,EACP,WAAW,EACX,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACpB,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AAEH;;;;;;GAMG;AACH,iBAAe,oBAAoB,CAC/B,WAAW,EAAE,QAAQ,EACrB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAO,GAAG,WAAgB,GACpC,OAAO,CAAC,QAAQ,CAAC,CA2BnB;AAED,OAAO,EACH,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,iBAAiB,GACpB,CAAC;AACF,YAAY,EACR,QAAQ,EAAE,EAAE;AACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,GACpB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { generateLockfile } from "./generate_lockfile.js";
|
|
2
|
+
import { generateReadmeFiles } from "./generate_readme.js";
|
|
3
|
+
import { generateGitignoreRules } from "./generate_gitignore.js";
|
|
4
|
+
import { generateJson, normalizeDependencies } from "./generate_json.js";
|
|
5
|
+
import generateLicense from "./generate_license.js";
|
|
6
|
+
import { logm } from "./logger.js";
|
|
7
|
+
import { promptUserForInfo } from "./user_prompts.js";
|
|
8
|
+
import { getModpackInfo, getLockfile } from "./directory_scanning.js";
|
|
9
|
+
/**
|
|
10
|
+
* @license MIT
|
|
11
|
+
* @author nickesc
|
|
12
|
+
* @module modpack-lock
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Generate the modpack files (lockfile, JSON, and optionally license, gitignore, and readme)
|
|
16
|
+
* @param modpackInfo - The Jsonfile object containing the modpack information
|
|
17
|
+
* @param workingDir - The directory to generate the files in
|
|
18
|
+
* @param options - The options object
|
|
19
|
+
* @returns The lockfile object
|
|
20
|
+
*/
|
|
21
|
+
async function generateModpackFiles(modpackInfo, workingDir, options = {}) {
|
|
22
|
+
logm.quietFromOptions(options);
|
|
23
|
+
const lockfile = await generateLockfile(workingDir, options);
|
|
24
|
+
await generateJson(modpackInfo, lockfile, workingDir, options);
|
|
25
|
+
if (options.licenseFile || options.gitignore || options.readme) {
|
|
26
|
+
logm.header("Generating Optional Files");
|
|
27
|
+
}
|
|
28
|
+
// Generate license if requested
|
|
29
|
+
if (options.licenseFile) {
|
|
30
|
+
await generateLicense(modpackInfo, workingDir, options);
|
|
31
|
+
}
|
|
32
|
+
// Generate gitignore if requested
|
|
33
|
+
if (options.gitignore) {
|
|
34
|
+
await generateGitignoreRules(lockfile, workingDir, options);
|
|
35
|
+
}
|
|
36
|
+
// Generate README files if requested
|
|
37
|
+
if (options.readme) {
|
|
38
|
+
await generateReadmeFiles(lockfile, workingDir, options);
|
|
39
|
+
}
|
|
40
|
+
return lockfile;
|
|
41
|
+
}
|
|
42
|
+
export { generateModpackFiles, generateJson, normalizeDependencies, generateLockfile, generateGitignoreRules, generateReadmeFiles, generateLicense, getModpackInfo, getLockfile, promptUserForInfo, };
|
|
43
|
+
//# sourceMappingURL=modpack-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modpack-lock.js","sourceRoot":"","sources":["../src/modpack-lock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAC,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAC,YAAY,EAAE,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAC,iBAA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+
import type { ContentVersion, ProjectResponseItem, UserResponseItem } from "./types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fetch version information for multiple file hashes from the Modrinth API
|
|
5
|
+
* @param hashes - An array of hashes to fetch version information for
|
|
6
|
+
* @returns An object with the version information for each hash
|
|
7
|
+
*/
|
|
8
|
+
export declare function getVersionsFromHashes(hashes: string[]): Promise<Record<string, ContentVersion>>;
|
|
9
|
+
/**
|
|
10
|
+
* Fetch multiple projects by their IDs from the Modrinth API
|
|
11
|
+
* @param projectIds - An array of project IDs to fetch
|
|
12
|
+
* @returns An array of project objects
|
|
13
|
+
*/
|
|
14
|
+
export declare function getProjects(projectIds: string[]): Promise<ProjectResponseItem[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch multiple users by their IDs from the Modrinth API
|
|
17
|
+
* @param userIds - An array of user IDs to fetch
|
|
18
|
+
* @returns An array of user information objects
|
|
19
|
+
*/
|
|
20
|
+
export declare function getUsers(userIds: string[]): Promise<UserResponseItem[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Fetch Minecraft versions from the Modrinth API
|
|
23
|
+
* @returns An array of Minecraft versions for use with a prompt
|
|
24
|
+
*/
|
|
25
|
+
export declare function getMinecraftVersions(): Promise<Choice[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch modloaders from the Modrinth API
|
|
28
|
+
* @returns An array of modloaders for use with a prompt
|
|
29
|
+
*/
|
|
30
|
+
export declare function getModloaders(): Promise<Choice[]>;
|
|
31
|
+
//# sourceMappingURL=modrinth_interactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modrinth_interactions.d.ts","sourceRoot":"","sources":["../src/modrinth_interactions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EACR,cAAc,EACd,mBAAmB,EAGnB,gBAAgB,EACnB,MAAM,kBAAkB,CAAC;AAa1B;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAiCrG;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAoCtF;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAoC7E;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAkC9D;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CA2BvD"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as config from "./config/index.js";
|
|
2
|
-
import {logm} from "./logger.js";
|
|
3
|
-
|
|
2
|
+
import { logm } from "./logger.js";
|
|
4
3
|
/**
|
|
5
4
|
* Split an array into chunks of specified size
|
|
6
5
|
*/
|
|
@@ -11,15 +10,15 @@ function chunkArray(array, size) {
|
|
|
11
10
|
}
|
|
12
11
|
return chunks;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
14
|
+
* Fetch version information for multiple file hashes from the Modrinth API
|
|
15
|
+
* @param hashes - An array of hashes to fetch version information for
|
|
16
|
+
* @returns An object with the version information for each hash
|
|
17
17
|
*/
|
|
18
18
|
export async function getVersionsFromHashes(hashes) {
|
|
19
19
|
if (hashes.length === 0) {
|
|
20
20
|
return {};
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
try {
|
|
24
23
|
const response = await fetch(config.MODRINTH_VERSION_FILES_ENDPOINT, {
|
|
25
24
|
method: "POST",
|
|
@@ -31,31 +30,35 @@ export async function getVersionsFromHashes(hashes) {
|
|
|
31
30
|
hashes: hashes,
|
|
32
31
|
algorithm: "sha1",
|
|
33
32
|
}),
|
|
33
|
+
signal: AbortSignal.timeout(config.MODRINTH_API_TIMEOUT),
|
|
34
34
|
});
|
|
35
|
-
|
|
36
35
|
if (!response.ok) {
|
|
37
36
|
const errorText = await response.text();
|
|
38
37
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
return (await response.json());
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
logm.error(`Error fetching version information from hashes: ${error.message}`);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw new Error(`Unknown error fetching version information from hashes`);
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
|
-
|
|
48
51
|
/**
|
|
49
|
-
* Fetch multiple projects by their IDs
|
|
52
|
+
* Fetch multiple projects by their IDs from the Modrinth API
|
|
53
|
+
* @param projectIds - An array of project IDs to fetch
|
|
54
|
+
* @returns An array of project objects
|
|
50
55
|
*/
|
|
51
56
|
export async function getProjects(projectIds) {
|
|
52
57
|
if (projectIds.length === 0) {
|
|
53
58
|
return [];
|
|
54
59
|
}
|
|
55
|
-
|
|
56
60
|
const chunks = chunkArray(projectIds, config.BATCH_SIZE);
|
|
57
61
|
const results = [];
|
|
58
|
-
|
|
59
62
|
for (const chunk of chunks) {
|
|
60
63
|
try {
|
|
61
64
|
const url = `${config.MODRINTH_PROJECTS_ENDPOINT}?ids=${encodeURIComponent(JSON.stringify(chunk))}`;
|
|
@@ -63,35 +66,38 @@ export async function getProjects(projectIds) {
|
|
|
63
66
|
headers: {
|
|
64
67
|
"User-Agent": config.PACKAGE_USER_AGENT,
|
|
65
68
|
},
|
|
69
|
+
signal: AbortSignal.timeout(config.MODRINTH_API_TIMEOUT),
|
|
66
70
|
});
|
|
67
|
-
|
|
68
71
|
if (!response.ok) {
|
|
69
72
|
const errorText = await response.text();
|
|
70
73
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
71
74
|
}
|
|
72
|
-
|
|
73
|
-
const data = await response.json();
|
|
75
|
+
const data = (await response.json());
|
|
74
76
|
results.push(...data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
logm.error(`Error fetching projects: ${error.message}`);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new Error(`Unknown error fetching projects`);
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
|
-
|
|
81
88
|
return results;
|
|
82
89
|
}
|
|
83
|
-
|
|
84
90
|
/**
|
|
85
|
-
* Fetch multiple users by their IDs
|
|
91
|
+
* Fetch multiple users by their IDs from the Modrinth API
|
|
92
|
+
* @param userIds - An array of user IDs to fetch
|
|
93
|
+
* @returns An array of user information objects
|
|
86
94
|
*/
|
|
87
95
|
export async function getUsers(userIds) {
|
|
88
96
|
if (userIds.length === 0) {
|
|
89
97
|
return [];
|
|
90
98
|
}
|
|
91
|
-
|
|
92
99
|
const chunks = chunkArray(userIds, config.BATCH_SIZE);
|
|
93
100
|
const results = [];
|
|
94
|
-
|
|
95
101
|
for (const chunk of chunks) {
|
|
96
102
|
try {
|
|
97
103
|
const url = `${config.MODRINTH_USERS_ENDPOINT}?ids=${encodeURIComponent(JSON.stringify(chunk))}`;
|
|
@@ -99,27 +105,30 @@ export async function getUsers(userIds) {
|
|
|
99
105
|
headers: {
|
|
100
106
|
"User-Agent": config.PACKAGE_USER_AGENT,
|
|
101
107
|
},
|
|
108
|
+
signal: AbortSignal.timeout(config.MODRINTH_API_TIMEOUT),
|
|
102
109
|
});
|
|
103
|
-
|
|
104
110
|
if (!response.ok) {
|
|
105
111
|
const errorText = await response.text();
|
|
106
112
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
107
113
|
}
|
|
108
|
-
|
|
109
|
-
const data = await response.json();
|
|
114
|
+
const data = (await response.json());
|
|
110
115
|
results.push(...data);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof Error) {
|
|
119
|
+
logm.error(`Error fetching users: ${error.message}`);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
throw new Error(`Unknown error fetching users`);
|
|
124
|
+
}
|
|
114
125
|
}
|
|
115
126
|
}
|
|
116
|
-
|
|
117
127
|
return results;
|
|
118
128
|
}
|
|
119
|
-
|
|
120
129
|
/**
|
|
121
|
-
* Fetch Minecraft versions from Modrinth
|
|
122
|
-
* @returns
|
|
130
|
+
* Fetch Minecraft versions from the Modrinth API
|
|
131
|
+
* @returns An array of Minecraft versions for use with a prompt
|
|
123
132
|
*/
|
|
124
133
|
export async function getMinecraftVersions() {
|
|
125
134
|
try {
|
|
@@ -128,34 +137,36 @@ export async function getMinecraftVersions() {
|
|
|
128
137
|
headers: {
|
|
129
138
|
"User-Agent": config.PACKAGE_USER_AGENT,
|
|
130
139
|
},
|
|
140
|
+
signal: AbortSignal.timeout(config.MODRINTH_API_TIMEOUT),
|
|
131
141
|
});
|
|
132
142
|
if (!response.ok) {
|
|
133
143
|
const errorText = await response.text();
|
|
134
144
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
135
145
|
}
|
|
136
|
-
|
|
137
|
-
const json = await response.json();
|
|
146
|
+
const json = (await response.json());
|
|
138
147
|
if (json) {
|
|
139
148
|
//sort by version type (in the order of the MINECRAFT_VERSION_TYPES array)
|
|
140
149
|
json.sort((a, b) => {
|
|
141
|
-
return (
|
|
142
|
-
config.
|
|
143
|
-
config.MINECRAFT_VERSION_TYPES.indexOf(b.version_type)
|
|
144
|
-
);
|
|
150
|
+
return (config.MINECRAFT_VERSION_TYPE_ORDER.indexOf(a.version_type) -
|
|
151
|
+
config.MINECRAFT_VERSION_TYPE_ORDER.indexOf(b.version_type));
|
|
145
152
|
});
|
|
146
|
-
return json.map((version) => ({
|
|
147
|
-
|
|
148
|
-
|
|
153
|
+
return json.map((version) => ({
|
|
154
|
+
title: version.version,
|
|
155
|
+
value: version.version,
|
|
156
|
+
}));
|
|
149
157
|
}
|
|
150
|
-
|
|
158
|
+
else {
|
|
159
|
+
throw new Error("Could not fetch Minecraft versions");
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
151
163
|
logm.warn(`Could not fetch Minecraft versions. Using fallbacks.`);
|
|
152
164
|
return config.FALLBACK_TARGET_MINECRAFT_VERSIONS;
|
|
153
165
|
}
|
|
154
166
|
}
|
|
155
|
-
|
|
156
167
|
/**
|
|
157
|
-
* Fetch
|
|
158
|
-
* @returns
|
|
168
|
+
* Fetch modloaders from the Modrinth API
|
|
169
|
+
* @returns An array of modloaders for use with a prompt
|
|
159
170
|
*/
|
|
160
171
|
export async function getModloaders() {
|
|
161
172
|
try {
|
|
@@ -164,20 +175,26 @@ export async function getModloaders() {
|
|
|
164
175
|
headers: {
|
|
165
176
|
"User-Agent": config.PACKAGE_USER_AGENT,
|
|
166
177
|
},
|
|
178
|
+
signal: AbortSignal.timeout(config.MODRINTH_API_TIMEOUT),
|
|
167
179
|
});
|
|
168
180
|
if (!response.ok) {
|
|
169
181
|
const errorText = await response.text();
|
|
170
182
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
171
183
|
}
|
|
172
|
-
|
|
173
|
-
const json = await response.json();
|
|
184
|
+
const json = (await response.json());
|
|
174
185
|
if (json) {
|
|
175
|
-
return json.map((loader) => ({
|
|
176
|
-
|
|
177
|
-
|
|
186
|
+
return json.map((loader) => ({
|
|
187
|
+
title: loader.name,
|
|
188
|
+
value: loader.name,
|
|
189
|
+
}));
|
|
178
190
|
}
|
|
179
|
-
|
|
191
|
+
else {
|
|
192
|
+
throw new Error("Could not fetch Modloaders");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
180
196
|
logm.warn(`Could not fetch Modloaders. Using fallbacks.`);
|
|
181
197
|
return config.FALLBACK_MODLOADERS;
|
|
182
198
|
}
|
|
183
199
|
}
|
|
200
|
+
//# sourceMappingURL=modrinth_interactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modrinth_interactions.js","sourceRoot":"","sources":["../src/modrinth_interactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAUjC;;GAEG;AACH,SAAS,UAAU,CAAC,KAAY,EAAE,IAAY;IAC1C,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAgB;IACxD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,+BAA+B,EAAE;YACjE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,YAAY,EAAE,MAAM,CAAC,kBAAkB;aAC1C;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACjB,MAAM,EAAE,MAAM;gBACd,SAAS,EAAE,MAAM;aACpB,CAAC;YACF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C,oBAAoB,CAAC;SAC3D,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,uBAAuB,QAAQ,CAAC,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC;QAC7E,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA4B,CAAC;QAChE,IAAI,IAAI,EAAE,CAAC;YACP,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBACzB,KAAK,EAAE,MAAM,CAAC,IAAI;gBAClB,KAAK,EAAE,MAAM,CAAC,IAAI;aACrB,CAAC,CAAC,CAAC;QACR,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACL,IAAI,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAC1D,OAAO,MAAM,CAAC,mBAAmB,CAAC;IACtC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DependencyCategory, ModpackInfo } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A map of content names (Modrinth slugs or file paths) to version strings.
|
|
4
|
+
* Non-Modrinth content uses `"*"` to indicate an unversioned/local file.
|
|
5
|
+
*/
|
|
6
|
+
export type DependencyMap = Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Legacy dependency format: a flat array of name strings without version info.
|
|
9
|
+
* Accepted on read for backward compatibility; normalised to {@link DependencyMap}
|
|
10
|
+
* via {@link normalizeDependencies} at runtime.
|
|
11
|
+
*/
|
|
12
|
+
export type LegacyDependencyList = string[];
|
|
13
|
+
/**
|
|
14
|
+
* The modpack.json file's shape; contains the modpack information and dependencies
|
|
15
|
+
* @property dependencies - The dependencies of the modpack
|
|
16
|
+
* @property scripts - The scripts of the modpack
|
|
17
|
+
* @property [key: string] - Any other properties of the modpack
|
|
18
|
+
*/
|
|
19
|
+
export type Jsonfile = Partial<ModpackInfo> & {
|
|
20
|
+
dependencies?: Partial<Record<DependencyCategory, DependencyMap | LegacyDependencyList>>;
|
|
21
|
+
scripts?: {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=Jsonfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Jsonfile.d.ts","sourceRoot":"","sources":["../../src/types/Jsonfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,YAAY,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,GAAG,oBAAoB,CAAC,CAAC,CAAC;IACzF,OAAO,CAAC,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACzB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Jsonfile.js","sourceRoot":"","sources":["../../src/types/Jsonfile.ts"],"names":[],"mappings":""}
|