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 → 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,CAAC;QACpB,KAAK,EAAE,CAAC,SAAS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AAC,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 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, 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, generateLockfile, generateGitignoreRules, generateReadmeFiles, generateLicense, getModpackInfo, getLockfile, promptUserForInfo, };
|
|
23
|
+
export type { Lockfile, //
|
|
24
|
+
ModpackInfo, Jsonfile, 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,YAAY,MAAM,oBAAoB,CAAC;AAC9C,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,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,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,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,GACpB,CAAC"}
|
|
@@ -1,69 +1,43 @@
|
|
|
1
|
-
import {generateLockfile} from "./generate_lockfile.js";
|
|
2
|
-
import {generateReadmeFiles} from "./generate_readme.js";
|
|
3
|
-
import {generateGitignoreRules} from "./generate_gitignore.js";
|
|
1
|
+
import { generateLockfile } from "./generate_lockfile.js";
|
|
2
|
+
import { generateReadmeFiles } from "./generate_readme.js";
|
|
3
|
+
import { generateGitignoreRules } from "./generate_gitignore.js";
|
|
4
4
|
import generateJson from "./generate_json.js";
|
|
5
5
|
import generateLicense from "./generate_license.js";
|
|
6
|
-
import {logm} from "./logger.js";
|
|
7
|
-
import {promptUserForInfo} from "./
|
|
8
|
-
import {getModpackInfo, getLockfile} from "./directory_scanning.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @typedef {import('./config/types.js').ModpackInfo} ModpackInfo
|
|
12
|
-
* @typedef {import('./config/types.js').Options} Options
|
|
13
|
-
* @typedef {import('./config/types.js').InitOptions} InitOptions
|
|
14
|
-
* @typedef {import('./config/types.js').Lockfile} Lockfile
|
|
15
|
-
*/
|
|
16
|
-
|
|
6
|
+
import { logm } from "./logger.js";
|
|
7
|
+
import { promptUserForInfo } from "./user_prompts.js";
|
|
8
|
+
import { getModpackInfo, getLockfile } from "./directory_scanning.js";
|
|
17
9
|
/**
|
|
18
10
|
* @license MIT
|
|
19
11
|
* @author nickesc
|
|
20
12
|
* @module modpack-lock
|
|
21
13
|
*/
|
|
22
|
-
|
|
23
14
|
/**
|
|
24
15
|
* Generate the modpack files (lockfile, JSON, and optionally license, gitignore, and readme)
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
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
|
|
29
20
|
*/
|
|
30
21
|
async function generateModpackFiles(modpackInfo, workingDir, options = {}) {
|
|
31
22
|
logm.quietFromOptions(options);
|
|
32
|
-
|
|
33
23
|
const lockfile = await generateLockfile(workingDir, options);
|
|
34
|
-
|
|
35
24
|
await generateJson(modpackInfo, lockfile, workingDir, options);
|
|
36
|
-
|
|
37
25
|
if (options.licenseFile || options.gitignore || options.readme) {
|
|
38
26
|
logm.header("Generating Optional Files");
|
|
39
27
|
}
|
|
40
|
-
|
|
41
28
|
// Generate license if requested
|
|
42
29
|
if (options.licenseFile) {
|
|
43
30
|
await generateLicense(modpackInfo, workingDir, options);
|
|
44
31
|
}
|
|
45
|
-
|
|
46
32
|
// Generate gitignore if requested
|
|
47
33
|
if (options.gitignore) {
|
|
48
34
|
await generateGitignoreRules(lockfile, workingDir, options);
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
// Generate README files if requested
|
|
52
37
|
if (options.readme) {
|
|
53
38
|
await generateReadmeFiles(lockfile, workingDir, options);
|
|
54
39
|
}
|
|
55
|
-
|
|
56
40
|
return lockfile;
|
|
57
41
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
generateModpackFiles,
|
|
61
|
-
generateJson,
|
|
62
|
-
generateLockfile,
|
|
63
|
-
generateGitignoreRules,
|
|
64
|
-
generateReadmeFiles,
|
|
65
|
-
generateLicense,
|
|
66
|
-
getModpackInfo,
|
|
67
|
-
getLockfile,
|
|
68
|
-
promptUserForInfo,
|
|
69
|
-
};
|
|
42
|
+
export { generateModpackFiles, generateJson, 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,YAAY,MAAM,oBAAoB,CAAC;AAC9C,OAAO,eAAe,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,cAAc,EAAE,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAapE;;;;GAIG;AAEH;;;;;;GAMG;AACH,KAAK,UAAU,oBAAoB,CAC/B,WAAqB,EACrB,UAAkB,EAClB,UAAiC,EAAE;IAEnC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE/B,MAAM,QAAQ,GAAa,MAAM,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEvE,MAAM,YAAY,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAE/D,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC;IAC7C,CAAC;IAED,gCAAgC;IAChC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACtB,MAAM,eAAe,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,kCAAkC;IAClC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACpB,MAAM,sBAAsB,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED,qCAAqC;IACrC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACjB,MAAM,mBAAmB,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,OAAO,EACH,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,iBAAiB,GACpB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Choice } from "prompts";
|
|
2
|
+
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,CAgCrG;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAmCtF;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAmC7E;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAiC9D;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CA0BvD"}
|
|
@@ -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",
|
|
@@ -32,30 +31,33 @@ export async function getVersionsFromHashes(hashes) {
|
|
|
32
31
|
algorithm: "sha1",
|
|
33
32
|
}),
|
|
34
33
|
});
|
|
35
|
-
|
|
36
34
|
if (!response.ok) {
|
|
37
35
|
const errorText = await response.text();
|
|
38
36
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
return (await response.json());
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
logm.error(`Error fetching version information from hashes: ${error.message}`);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw new Error(`Unknown error fetching version information from hashes`);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
|
|
48
50
|
/**
|
|
49
|
-
* Fetch multiple projects by their IDs
|
|
51
|
+
* Fetch multiple projects by their IDs from the Modrinth API
|
|
52
|
+
* @param projectIds - An array of project IDs to fetch
|
|
53
|
+
* @returns An array of project objects
|
|
50
54
|
*/
|
|
51
55
|
export async function getProjects(projectIds) {
|
|
52
56
|
if (projectIds.length === 0) {
|
|
53
57
|
return [];
|
|
54
58
|
}
|
|
55
|
-
|
|
56
59
|
const chunks = chunkArray(projectIds, config.BATCH_SIZE);
|
|
57
60
|
const results = [];
|
|
58
|
-
|
|
59
61
|
for (const chunk of chunks) {
|
|
60
62
|
try {
|
|
61
63
|
const url = `${config.MODRINTH_PROJECTS_ENDPOINT}?ids=${encodeURIComponent(JSON.stringify(chunk))}`;
|
|
@@ -64,34 +66,36 @@ export async function getProjects(projectIds) {
|
|
|
64
66
|
"User-Agent": config.PACKAGE_USER_AGENT,
|
|
65
67
|
},
|
|
66
68
|
});
|
|
67
|
-
|
|
68
69
|
if (!response.ok) {
|
|
69
70
|
const errorText = await response.text();
|
|
70
71
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
-
const data = await response.json();
|
|
73
|
+
const data = (await response.json());
|
|
74
74
|
results.push(...data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (error instanceof Error) {
|
|
78
|
+
logm.error(`Error fetching projects: ${error.message}`);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw new Error(`Unknown error fetching projects`);
|
|
83
|
+
}
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
|
-
|
|
81
86
|
return results;
|
|
82
87
|
}
|
|
83
|
-
|
|
84
88
|
/**
|
|
85
|
-
* Fetch multiple users by their IDs
|
|
89
|
+
* Fetch multiple users by their IDs from the Modrinth API
|
|
90
|
+
* @param userIds - An array of user IDs to fetch
|
|
91
|
+
* @returns An array of user information objects
|
|
86
92
|
*/
|
|
87
93
|
export async function getUsers(userIds) {
|
|
88
94
|
if (userIds.length === 0) {
|
|
89
95
|
return [];
|
|
90
96
|
}
|
|
91
|
-
|
|
92
97
|
const chunks = chunkArray(userIds, config.BATCH_SIZE);
|
|
93
98
|
const results = [];
|
|
94
|
-
|
|
95
99
|
for (const chunk of chunks) {
|
|
96
100
|
try {
|
|
97
101
|
const url = `${config.MODRINTH_USERS_ENDPOINT}?ids=${encodeURIComponent(JSON.stringify(chunk))}`;
|
|
@@ -100,26 +104,28 @@ export async function getUsers(userIds) {
|
|
|
100
104
|
"User-Agent": config.PACKAGE_USER_AGENT,
|
|
101
105
|
},
|
|
102
106
|
});
|
|
103
|
-
|
|
104
107
|
if (!response.ok) {
|
|
105
108
|
const errorText = await response.text();
|
|
106
109
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
107
110
|
}
|
|
108
|
-
|
|
109
|
-
const data = await response.json();
|
|
111
|
+
const data = (await response.json());
|
|
110
112
|
results.push(...data);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error instanceof Error) {
|
|
116
|
+
logm.error(`Error fetching users: ${error.message}`);
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new Error(`Unknown error fetching users`);
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
|
-
|
|
117
124
|
return results;
|
|
118
125
|
}
|
|
119
|
-
|
|
120
126
|
/**
|
|
121
|
-
* Fetch Minecraft versions from Modrinth
|
|
122
|
-
* @returns
|
|
127
|
+
* Fetch Minecraft versions from the Modrinth API
|
|
128
|
+
* @returns An array of Minecraft versions for use with a prompt
|
|
123
129
|
*/
|
|
124
130
|
export async function getMinecraftVersions() {
|
|
125
131
|
try {
|
|
@@ -133,29 +139,30 @@ export async function getMinecraftVersions() {
|
|
|
133
139
|
const errorText = await response.text();
|
|
134
140
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
135
141
|
}
|
|
136
|
-
|
|
137
|
-
const json = await response.json();
|
|
142
|
+
const json = (await response.json());
|
|
138
143
|
if (json) {
|
|
139
144
|
//sort by version type (in the order of the MINECRAFT_VERSION_TYPES array)
|
|
140
145
|
json.sort((a, b) => {
|
|
141
|
-
return (
|
|
142
|
-
config.
|
|
143
|
-
config.MINECRAFT_VERSION_TYPES.indexOf(b.version_type)
|
|
144
|
-
);
|
|
146
|
+
return (config.MINECRAFT_VERSION_TYPE_ORDER.indexOf(a.version_type) -
|
|
147
|
+
config.MINECRAFT_VERSION_TYPE_ORDER.indexOf(b.version_type));
|
|
145
148
|
});
|
|
146
|
-
return json.map((version) => ({
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
return json.map((version) => ({
|
|
150
|
+
title: version.version,
|
|
151
|
+
value: version.version,
|
|
152
|
+
}));
|
|
149
153
|
}
|
|
150
|
-
|
|
154
|
+
else {
|
|
155
|
+
throw new Error("Could not fetch Minecraft versions");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
151
159
|
logm.warn(`Could not fetch Minecraft versions. Using fallbacks.`);
|
|
152
160
|
return config.FALLBACK_TARGET_MINECRAFT_VERSIONS;
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
|
-
|
|
156
163
|
/**
|
|
157
|
-
* Fetch
|
|
158
|
-
* @returns
|
|
164
|
+
* Fetch modloaders from the Modrinth API
|
|
165
|
+
* @returns An array of modloaders for use with a prompt
|
|
159
166
|
*/
|
|
160
167
|
export async function getModloaders() {
|
|
161
168
|
try {
|
|
@@ -169,15 +176,20 @@ export async function getModloaders() {
|
|
|
169
176
|
const errorText = await response.text();
|
|
170
177
|
throw new Error(`Modrinth API error (${response.status}): ${errorText}`);
|
|
171
178
|
}
|
|
172
|
-
|
|
173
|
-
const json = await response.json();
|
|
179
|
+
const json = (await response.json());
|
|
174
180
|
if (json) {
|
|
175
|
-
return json.map((loader) => ({
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
return json.map((loader) => ({
|
|
182
|
+
title: loader.name,
|
|
183
|
+
value: loader.name,
|
|
184
|
+
}));
|
|
178
185
|
}
|
|
179
|
-
|
|
186
|
+
else {
|
|
187
|
+
throw new Error("Could not fetch Modloaders");
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
180
191
|
logm.warn(`Could not fetch Modloaders. Using fallbacks.`);
|
|
181
192
|
return config.FALLBACK_MODLOADERS;
|
|
182
193
|
}
|
|
183
194
|
}
|
|
195
|
+
//# 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,kBAA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C;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,15 @@
|
|
|
1
|
+
import type { DependencyCategory, ModpackInfo } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The modpack.json file's shape; contains the modpack information and dependencies
|
|
4
|
+
* @property dependencies - The dependencies of the modpack
|
|
5
|
+
* @property scripts - The scripts of the modpack
|
|
6
|
+
* @property [key: string] - Any other properties of the modpack
|
|
7
|
+
*/
|
|
8
|
+
export type Jsonfile = Partial<ModpackInfo> & {
|
|
9
|
+
dependencies?: Partial<Record<DependencyCategory, string[]>>;
|
|
10
|
+
scripts?: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
//# 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;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7D,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":""}
|