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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/config/files.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,eAAO,MAAM,qBAAqB,EAAE,MAAuB,CAAC;AAE5D,oCAAoC;AACpC,eAAO,MAAM,iBAAiB,EAAE,MAAuB,CAAC;AAExD,wBAAwB;AACxB,eAAO,MAAM,oBAAoB,EAAE,MAAkB,CAAC;AAEtD,0BAA0B;AAC1B,eAAO,MAAM,cAAc,EAAE,MAAqB,CAAC;AAEnD,0BAA0B;AAC1B,eAAO,MAAM,WAAW,EAAE,MAAoB,CAAC"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/** Machine-readable/lockfile name */
|
|
2
2
|
export const MODPACK_LOCKFILE_NAME = "modpack.lock";
|
|
3
|
-
|
|
4
3
|
/** Human-readable/JSON file name */
|
|
5
4
|
export const MODPACK_JSON_NAME = "modpack.json";
|
|
6
|
-
|
|
7
5
|
/** License file name */
|
|
8
6
|
export const MODPACK_LICENSE_NAME = "LICENSE";
|
|
9
|
-
|
|
10
7
|
/** Gitignore file name */
|
|
11
8
|
export const GITIGNORE_NAME = ".gitignore";
|
|
12
|
-
|
|
13
9
|
/** README.md file name */
|
|
14
10
|
export const README_NAME = "README.md";
|
|
11
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/config/files.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAW,cAAc,CAAC;AAE5D,oCAAoC;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAW,cAAc,CAAC;AAExD,wBAAwB;AACxB,MAAM,CAAC,MAAM,oBAAoB,GAAW,SAAS,CAAC;AAEtD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAW,YAAY,CAAC;AAEnD,0BAA0B;AAC1B,MAAM,CAAC,MAAM,WAAW,GAAW,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Options as slugifyOptions } from "@sindresorhus/slugify";
|
|
2
|
+
/** Options for slugify */
|
|
3
|
+
export declare const SLUGIFY_OPTIONS: slugifyOptions;
|
|
4
|
+
/** Options for prompts */
|
|
5
|
+
export declare const PROMPTS_OPTIONS: {
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/config/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAErE,0BAA0B;AAC1B,eAAO,MAAM,eAAe,EAAE,cAQ7B,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,eAAe,EAAE;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAC;CAMxB,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {logm} from "../logger.js";
|
|
2
|
-
|
|
1
|
+
import { logm } from "../logger.js";
|
|
3
2
|
/** Options for slugify */
|
|
4
3
|
export const SLUGIFY_OPTIONS = {
|
|
5
|
-
|
|
6
|
-
strict: true,
|
|
4
|
+
lowercase: true,
|
|
7
5
|
separator: "-",
|
|
8
6
|
locale: "en",
|
|
9
|
-
|
|
7
|
+
transliterate: true,
|
|
8
|
+
preserveTrailingDash: false,
|
|
9
|
+
preserveLeadingUnderscore: false,
|
|
10
|
+
decamelize: false,
|
|
10
11
|
};
|
|
11
|
-
|
|
12
12
|
/** Options for prompts */
|
|
13
13
|
export const PROMPTS_OPTIONS = {
|
|
14
14
|
onCancel: () => {
|
|
@@ -16,3 +16,4 @@ export const PROMPTS_OPTIONS = {
|
|
|
16
16
|
process.exit(1);
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/config/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAGlC,0BAA0B;AAC1B,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC3C,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,GAAG;IACd,MAAM,EAAE,IAAI;IACZ,aAAa,EAAE,IAAI;IACnB,oBAAoB,EAAE,KAAK;IAC3B,yBAAyB,EAAE,KAAK;IAChC,UAAU,EAAE,KAAK;CACpB,CAAC;AAEF,0BAA0B;AAC1B,MAAM,CAAC,MAAM,eAAe,GAExB;IACA,QAAQ,EAAE,GAAG,EAAE;QACX,IAAI,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import pkg from "../../package.json";
|
|
2
|
+
interface InfoField {
|
|
3
|
+
prompt: string;
|
|
4
|
+
option: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const infoFields: {
|
|
7
|
+
name: InfoField;
|
|
8
|
+
version: InfoField;
|
|
9
|
+
id: InfoField;
|
|
10
|
+
description: InfoField;
|
|
11
|
+
author: InfoField;
|
|
12
|
+
projectUrl: InfoField;
|
|
13
|
+
sourceUrl: InfoField;
|
|
14
|
+
license: InfoField;
|
|
15
|
+
modloader: InfoField;
|
|
16
|
+
targetModloaderVersion: InfoField;
|
|
17
|
+
targetMinecraftVersion: InfoField;
|
|
18
|
+
};
|
|
19
|
+
export declare const fileFields: {
|
|
20
|
+
addLicense: InfoField;
|
|
21
|
+
addGitignore: InfoField;
|
|
22
|
+
addReadme: InfoField;
|
|
23
|
+
};
|
|
24
|
+
export declare const headings: {
|
|
25
|
+
options: string;
|
|
26
|
+
generation: string;
|
|
27
|
+
logging: string;
|
|
28
|
+
packInfo: string;
|
|
29
|
+
information: string;
|
|
30
|
+
};
|
|
31
|
+
export declare const dryRunText: (filename: string, location: string) => string;
|
|
32
|
+
/** All-Rights-Reserved license text */
|
|
33
|
+
export declare const ARR_LICENSE_TEXT: string;
|
|
34
|
+
export { pkg };
|
|
35
|
+
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/config/strings.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,oBAAoB,CAAqB;AAEzD,UAAU,SAAS;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,UAAU,EAAE;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC;IACnB,EAAE,EAAE,SAAS,CAAC;IACd,WAAW,EAAE,SAAS,CAAC;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,sBAAsB,EAAE,SAAS,CAAC;IAClC,sBAAsB,EAAE,SAAS,CAAC;CA8CrC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,SAAS,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;CAcxB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CAOvB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAEhE,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,gBAAgB,EAAE,MAA8E,CAAC;AAE9G,OAAO,EAAC,GAAG,EAAC,CAAC"}
|
|
@@ -1,54 +1,52 @@
|
|
|
1
1
|
import * as defaults from "./defaults.js";
|
|
2
2
|
import * as files from "./files.js";
|
|
3
|
-
import pkg from "../../package.json" with {type: "json"};
|
|
4
|
-
|
|
3
|
+
import pkg from "../../package.json" with { type: "json" };
|
|
5
4
|
export const infoFields = {
|
|
6
5
|
name: {
|
|
7
6
|
prompt: "modpack name",
|
|
8
|
-
option: "
|
|
7
|
+
option: "The name of the modpack; defaults to the directory name",
|
|
9
8
|
},
|
|
10
9
|
version: {
|
|
11
10
|
prompt: "modpack version",
|
|
12
|
-
option: `
|
|
11
|
+
option: `The modpack version; defaults to ${defaults.DEFAULT_MODPACK_VERSION}`,
|
|
13
12
|
},
|
|
14
13
|
id: {
|
|
15
14
|
prompt: "modpack slug/ID",
|
|
16
|
-
option: "
|
|
15
|
+
option: "The modpack's slug/ID; defaults to the directory name slugified",
|
|
17
16
|
},
|
|
18
17
|
description: {
|
|
19
18
|
prompt: "modpack description",
|
|
20
|
-
option: "
|
|
19
|
+
option: "A description of the modpack",
|
|
21
20
|
},
|
|
22
21
|
author: {
|
|
23
22
|
prompt: "modpack author",
|
|
24
|
-
option: "
|
|
23
|
+
option: "The author of the modpack; required",
|
|
25
24
|
},
|
|
26
25
|
projectUrl: {
|
|
27
26
|
prompt: "modpack URL",
|
|
28
|
-
option: "
|
|
27
|
+
option: "The project's homepage URL; defaults to a guessed Modrinth project URL",
|
|
29
28
|
},
|
|
30
29
|
sourceUrl: {
|
|
31
30
|
prompt: "modpack source code URL",
|
|
32
|
-
option: "
|
|
31
|
+
option: "The project's source code URL; defaults to a guessed GitHub repository URL",
|
|
33
32
|
},
|
|
34
33
|
license: {
|
|
35
34
|
prompt: "modpack license",
|
|
36
|
-
option: `
|
|
35
|
+
option: `The modpack's license; popular licenses are fetched from GitHub; defaults to ${defaults.DEFAULT_MODPACK_LICENSE} in interactive mode`,
|
|
37
36
|
},
|
|
38
37
|
modloader: {
|
|
39
38
|
prompt: "modpack modloader",
|
|
40
|
-
option: "
|
|
39
|
+
option: "The modpack's modloader; a list of loaders is fetched from Modrinth; required",
|
|
41
40
|
},
|
|
42
41
|
targetModloaderVersion: {
|
|
43
42
|
prompt: "target modloader version",
|
|
44
|
-
option: "
|
|
43
|
+
option: "The target modloader version",
|
|
45
44
|
},
|
|
46
45
|
targetMinecraftVersion: {
|
|
47
46
|
prompt: "target Minecraft version",
|
|
48
|
-
option: "
|
|
47
|
+
option: "The target Minecraft version; a list of versions is fetched from Modrinth; required",
|
|
49
48
|
},
|
|
50
49
|
};
|
|
51
|
-
|
|
52
50
|
export const fileFields = {
|
|
53
51
|
addLicense: {
|
|
54
52
|
prompt: `Add the ${files.MODPACK_LICENSE_NAME} file`,
|
|
@@ -63,7 +61,6 @@ export const fileFields = {
|
|
|
63
61
|
option: `Generate ${files.README_NAME} files for each category`,
|
|
64
62
|
},
|
|
65
63
|
};
|
|
66
|
-
|
|
67
64
|
export const headings = {
|
|
68
65
|
options: "Options:",
|
|
69
66
|
generation: "GENERATION",
|
|
@@ -71,12 +68,10 @@ export const headings = {
|
|
|
71
68
|
packInfo: "MODPACK INFORMATION",
|
|
72
69
|
information: "INFORMATION",
|
|
73
70
|
};
|
|
74
|
-
|
|
75
71
|
export const dryRunText = (filename, location) => {
|
|
76
72
|
return `[DRY RUN] Would write ${filename} to: ${location}`;
|
|
77
73
|
};
|
|
78
|
-
|
|
79
74
|
/** All-Rights-Reserved license text */
|
|
80
75
|
export const ARR_LICENSE_TEXT = "Copyright (c) [year] [fullname]\n" + "\n" + "All rights reserved.\n";
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
export { pkg };
|
|
77
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/config/strings.ts"],"names":[],"mappings":"AAAA,O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BAAoB,sBAAsB;KACtE;IACD,YAAY,EAAE;QACV,MAAM,EAAE,cAAc,KAAK,CAAC,cAAc,OAAO;QACjD,MAAM,EAAE,cAAc,KAAK,CAAC,cAAc,4CAA4C;KACzF;IACD,SAAS,EAAE;QACP,MAAM,EAAE,YAAY,KAAK,CAAC,WAAW,QAAQ;QAC7C,MAAM,EAAE,YAAY,KAAK,CAAC,WAAW,0BAA0B;KAClE;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAMjB;IACA,OAAO,EAAE,UAAU;IACnB,UAAU,EAAE,YAAY;IACxB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,qBAAqB;IAC/B,WAAW,EAAE,aAAa;CAC7B,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAmD,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAC7F,OAAO,yBAAyB,QAAQ,QAAQ,QAAQ,EAAE,CAAC;AAC/D,CAAC,CAAC;AAEF,uCAAuC;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAW,mCAAmC,GAAG,IAAI,GAAG,wBAAwB,CAAC;AAE9G,OAAO,EAAC,GAAG,EAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Lockfile, Jsonfile } from "./types/index.js";
|
|
2
|
+
import type { ContentDirectory } from "./types/index.js";
|
|
3
|
+
import type { ContentFile } from "./types/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Get the directories to scan for modpack files
|
|
6
|
+
* @param directoryPath - The path to the directory to scan
|
|
7
|
+
* @returns The directories to scan
|
|
8
|
+
*/
|
|
9
|
+
export declare function getScanDirectories(directoryPath: string): ContentDirectory[];
|
|
10
|
+
/**
|
|
11
|
+
* Scan a directory and return file info with hashes
|
|
12
|
+
*/
|
|
13
|
+
export declare function scanDirectory(dirInfo: ContentDirectory, workspaceRoot: string): Promise<ContentFile[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the modpack info from the JSON file if it exists
|
|
16
|
+
* @param directoryPath - The path to the directory to scan
|
|
17
|
+
* @returns The Jsonfile object if the file exists, otherwise null
|
|
18
|
+
*/
|
|
19
|
+
export declare function getModpackInfo(directoryPath: string): Promise<Jsonfile | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Get the lockfile file if it exists
|
|
22
|
+
* @param directoryPath - The path to the directory to scan
|
|
23
|
+
* @returns The Lockfile object if the file exists, otherwise null
|
|
24
|
+
*/
|
|
25
|
+
export declare function getLockfile(directoryPath: string): Promise<Lockfile | null>;
|
|
26
|
+
//# sourceMappingURL=directory_scanning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory_scanning.d.ts","sourceRoot":"","sources":["../src/directory_scanning.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAM5E;AAmCD;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAqB5G;AAoBD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAEpF;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAEjF"}
|
|
@@ -2,26 +2,19 @@ import fs from "fs/promises";
|
|
|
2
2
|
import crypto from "crypto";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import * as config from "./config/index.js";
|
|
5
|
-
import {logm} from "./logger.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {import('./config/types.js').ModpackInfo} ModpackInfo
|
|
9
|
-
* @typedef {import('./config/types.js').Lockfile} Lockfile
|
|
10
|
-
*/
|
|
11
|
-
|
|
5
|
+
import { logm } from "./logger.js";
|
|
12
6
|
/**
|
|
13
7
|
* Get the directories to scan for modpack files
|
|
14
|
-
* @param
|
|
15
|
-
* @returns
|
|
8
|
+
* @param directoryPath - The path to the directory to scan
|
|
9
|
+
* @returns The directories to scan
|
|
16
10
|
*/
|
|
17
11
|
export function getScanDirectories(directoryPath) {
|
|
18
12
|
const scanDirectories = [];
|
|
19
13
|
for (const category of config.DEPENDENCY_CATEGORIES) {
|
|
20
|
-
scanDirectories.push({name: category, path: path.join(directoryPath, category)});
|
|
14
|
+
scanDirectories.push({ name: category, path: path.join(directoryPath, category) });
|
|
21
15
|
}
|
|
22
16
|
return scanDirectories;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
/**
|
|
26
19
|
* Calculate SHA1 hash of a file
|
|
27
20
|
*/
|
|
@@ -29,58 +22,51 @@ async function calculateSHA1(filePath) {
|
|
|
29
22
|
const fileBuffer = await fs.readFile(filePath);
|
|
30
23
|
return crypto.createHash("sha1").update(fileBuffer).digest("hex");
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
/**
|
|
34
26
|
* Find all files in a directory
|
|
35
27
|
*/
|
|
36
28
|
async function findFiles(dirPath) {
|
|
37
29
|
const files = [];
|
|
38
|
-
|
|
39
30
|
try {
|
|
40
|
-
const entries = await fs.readdir(dirPath, {withFileTypes: true});
|
|
41
|
-
|
|
31
|
+
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
42
32
|
for (const entry of entries) {
|
|
43
33
|
if (entry.isFile() && (entry.name.endsWith(".jar") || entry.name.endsWith(".zip"))) {
|
|
44
34
|
const fullPath = path.join(dirPath, entry.name);
|
|
45
35
|
files.push(fullPath);
|
|
46
36
|
}
|
|
47
37
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error?.code !== "ENOENT") {
|
|
50
41
|
logm.warn(`Could not read directory ${dirPath}: ${error.message}`);
|
|
51
42
|
}
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
files.sort((a, b) => a.localeCompare(b, "en", {numeric: true, sensitivity: "base"}));
|
|
44
|
+
files.sort((a, b) => a.localeCompare(b, "en", { numeric: true, sensitivity: "base" }));
|
|
55
45
|
return files;
|
|
56
46
|
}
|
|
57
|
-
|
|
58
47
|
/**
|
|
59
48
|
* Scan a directory and return file info with hashes
|
|
60
49
|
*/
|
|
61
50
|
export async function scanDirectory(dirInfo, workspaceRoot) {
|
|
62
51
|
const files = await findFiles(dirInfo.path);
|
|
63
52
|
const fileEntries = [];
|
|
64
|
-
|
|
65
53
|
for (const filePath of files) {
|
|
66
54
|
try {
|
|
67
55
|
const hash = await calculateSHA1(filePath);
|
|
68
56
|
const relativePath = path.relative(workspaceRoot, filePath);
|
|
69
|
-
|
|
70
57
|
fileEntries.push({
|
|
71
58
|
path: relativePath,
|
|
72
59
|
fullPath: filePath,
|
|
73
60
|
hash: hash,
|
|
74
61
|
category: dirInfo.name,
|
|
75
62
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
logm.error(`Could not hash file ${filePath}: ${error.message}`);
|
|
78
66
|
}
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
return fileEntries;
|
|
82
69
|
}
|
|
83
|
-
|
|
84
70
|
/**
|
|
85
71
|
* Scan for existing JSON file and return the JSON object if it exists
|
|
86
72
|
*/
|
|
@@ -90,29 +76,30 @@ async function getJsonFile(directoryPath, filename) {
|
|
|
90
76
|
try {
|
|
91
77
|
const fileContent = await fs.readFile(jsonPath, "utf-8");
|
|
92
78
|
return JSON.parse(fileContent);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error?.code !== "ENOENT") {
|
|
82
|
+
throw new Error(`Error: Could not read file ${jsonPath}: ${error.message}`, { cause: error });
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
97
85
|
return null;
|
|
98
86
|
}
|
|
99
87
|
}
|
|
100
88
|
}
|
|
101
|
-
|
|
102
89
|
/**
|
|
103
90
|
* Get the modpack info from the JSON file if it exists
|
|
104
|
-
* @param
|
|
105
|
-
* @returns
|
|
91
|
+
* @param directoryPath - The path to the directory to scan
|
|
92
|
+
* @returns The Jsonfile object if the file exists, otherwise null
|
|
106
93
|
*/
|
|
107
94
|
export async function getModpackInfo(directoryPath) {
|
|
108
95
|
return getJsonFile(directoryPath, config.MODPACK_JSON_NAME);
|
|
109
96
|
}
|
|
110
|
-
|
|
111
97
|
/**
|
|
112
98
|
* Get the lockfile file if it exists
|
|
113
|
-
* @param
|
|
114
|
-
* @returns
|
|
99
|
+
* @param directoryPath - The path to the directory to scan
|
|
100
|
+
* @returns The Lockfile object if the file exists, otherwise null
|
|
115
101
|
*/
|
|
116
102
|
export async function getLockfile(directoryPath) {
|
|
117
103
|
return getJsonFile(directoryPath, config.MODPACK_LOCKFILE_NAME);
|
|
118
104
|
}
|
|
105
|
+
//# sourceMappingURL=directory_scanning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory_scanning.js","sourceRoot":"","sources":["../src/directory_scanning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAKjC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAAqB;IACpD,MAAM,eAA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B,IAAI,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACzD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAI,KAAK,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;QAChG,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,aAAqB;IACtD,OAAO,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,aAAqB;IACnD,OAAO,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Lockfile, Options, InitOptions } from "./types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generate .gitignore rules for files not hosted on Modrinth and write them to .gitignore file
|
|
4
|
+
* @param lockfile - The lockfile object
|
|
5
|
+
* @param workingDir - The working directory
|
|
6
|
+
* @param options - The options object
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateGitignoreRules(lockfile: Lockfile, workingDir: string, options?: Options | InitOptions): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=generate_gitignore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_gitignore.d.ts","sourceRoot":"","sources":["../src/generate_gitignore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAErE;;;;;GAKG;AACH,wBAAsB,sBAAsB,CACxC,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAO,GAAG,WAAgB,GACpC,OAAO,CAAC,IAAI,CAAC,CA+Ff"}
|
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import * as config from "./config/index.js";
|
|
4
|
-
import {logm} from "./logger.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {import('./config/types.js').Options} Options
|
|
8
|
-
* @typedef {import('./config/types.js').InitOptions} InitOptions
|
|
9
|
-
* @typedef {import('./config/types.js').Lockfile} Lockfile
|
|
10
|
-
*/
|
|
11
|
-
|
|
4
|
+
import { logm } from "./logger.js";
|
|
12
5
|
/**
|
|
13
6
|
* Generate .gitignore rules for files not hosted on Modrinth and write them to .gitignore file
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
7
|
+
* @param lockfile - The lockfile object
|
|
8
|
+
* @param workingDir - The working directory
|
|
9
|
+
* @param options - The options object
|
|
17
10
|
*/
|
|
18
11
|
export async function generateGitignoreRules(lockfile, workingDir, options = {}) {
|
|
19
12
|
logm.quietFromOptions(options);
|
|
20
|
-
|
|
21
13
|
const rules = [];
|
|
22
14
|
const exceptions = [];
|
|
23
|
-
|
|
24
15
|
// Base ignore patterns for each category
|
|
25
16
|
for (const category of config.DEPENDENCY_CATEGORIES) {
|
|
26
17
|
rules.push(`${category}/*.${category === "mods" ? "jar" : "zip"}`);
|
|
27
18
|
}
|
|
28
19
|
rules.push(`*/**/*.disabled`);
|
|
29
|
-
|
|
30
20
|
// Find files not hosted on Modrinth
|
|
31
21
|
for (const [, entries] of Object.entries(lockfile.dependencies)) {
|
|
32
22
|
for (const entry of entries) {
|
|
@@ -35,79 +25,75 @@ export async function generateGitignoreRules(lockfile, workingDir, options = {})
|
|
|
35
25
|
}
|
|
36
26
|
}
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
// Add exceptions if any
|
|
40
29
|
if (exceptions.length > 0) {
|
|
41
30
|
rules.push("\n## Exceptions");
|
|
42
31
|
rules.push(...exceptions);
|
|
43
32
|
}
|
|
44
|
-
|
|
45
33
|
const rulesContent = rules.join("\n");
|
|
46
34
|
const gitignorePath = path.join(workingDir, config.GITIGNORE_NAME);
|
|
47
|
-
|
|
48
35
|
// Read existing .gitignore file if it exists
|
|
49
36
|
let existingContent = "";
|
|
50
37
|
try {
|
|
51
38
|
existingContent = await fs.readFile(gitignorePath, "utf-8");
|
|
52
|
-
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
53
41
|
// File doesn't exist, that's okay - we'll create it
|
|
54
|
-
if (error
|
|
42
|
+
if (error?.code !== "ENOENT") {
|
|
55
43
|
logm.warn(`Could not read ${config.GITIGNORE_NAME} file: ${error.message}`);
|
|
56
44
|
return;
|
|
57
45
|
}
|
|
58
46
|
}
|
|
59
|
-
|
|
60
47
|
// Find markers in existing content
|
|
61
48
|
const startMarkerIndex = existingContent.indexOf(config.GITIGNORE_START_MARKER);
|
|
62
49
|
const endMarkerIndex = existingContent.indexOf(config.GITIGNORE_END_MARKER);
|
|
63
|
-
|
|
64
50
|
let newContent;
|
|
65
|
-
|
|
66
51
|
if (startMarkerIndex !== -1 && endMarkerIndex !== -1 && endMarkerIndex > startMarkerIndex) {
|
|
67
52
|
// Both markers exist, replace content between them
|
|
68
53
|
const beforeSection = existingContent.substring(0, startMarkerIndex);
|
|
69
54
|
const afterSection = existingContent.substring(endMarkerIndex + config.GITIGNORE_END_MARKER.length);
|
|
70
|
-
|
|
71
55
|
// Remove trailing newlines from before section and leading newlines from after section
|
|
72
56
|
const beforeTrimmed = beforeSection.replace(/\n+$/, "");
|
|
73
57
|
const afterTrimmed = afterSection.replace(/^\n+/, "");
|
|
74
|
-
|
|
75
58
|
const parts = [beforeTrimmed];
|
|
76
|
-
if (beforeTrimmed)
|
|
59
|
+
if (beforeTrimmed)
|
|
60
|
+
parts.push(""); // Add separator if there's content before
|
|
77
61
|
parts.push(config.GITIGNORE_START_MARKER, rulesContent, config.GITIGNORE_END_MARKER);
|
|
78
62
|
if (afterTrimmed) {
|
|
79
63
|
parts.push(""); // Add separator if there's content after
|
|
80
64
|
parts.push(afterTrimmed);
|
|
81
65
|
}
|
|
82
|
-
|
|
83
66
|
newContent = parts.join("\n");
|
|
84
|
-
}
|
|
67
|
+
}
|
|
68
|
+
else if (startMarkerIndex !== -1 || endMarkerIndex !== -1) {
|
|
85
69
|
// Only one marker exists, append to end
|
|
86
70
|
const trimmed = existingContent.replace(/\n+$/, "");
|
|
87
71
|
newContent = [trimmed, "", config.GITIGNORE_START_MARKER, rulesContent, config.GITIGNORE_END_MARKER].join("\n");
|
|
88
|
-
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
89
74
|
// No markers exist, append to end
|
|
90
75
|
if (existingContent.trim() === "") {
|
|
91
76
|
// File is empty or only whitespace
|
|
92
77
|
newContent = [config.GITIGNORE_START_MARKER, rulesContent, config.GITIGNORE_END_MARKER].join("\n");
|
|
93
|
-
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
94
80
|
// File has content, append with newline
|
|
95
81
|
const trimmed = existingContent.replace(/\n+$/, "");
|
|
96
|
-
newContent = [trimmed, "", config.GITIGNORE_START_MARKER, rulesContent, config.GITIGNORE_END_MARKER].join(
|
|
97
|
-
"\n",
|
|
98
|
-
);
|
|
82
|
+
newContent = [trimmed, "", config.GITIGNORE_START_MARKER, rulesContent, config.GITIGNORE_END_MARKER].join("\n");
|
|
99
83
|
}
|
|
100
84
|
}
|
|
101
|
-
|
|
102
85
|
// Write the updated content
|
|
103
86
|
if (options.dryRun) {
|
|
104
87
|
logm.debug(config.dryRunText(config.GITIGNORE_NAME, gitignorePath));
|
|
105
|
-
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
106
90
|
try {
|
|
107
91
|
await fs.writeFile(gitignorePath, newContent, "utf-8");
|
|
108
92
|
logm.generated(config.GITIGNORE_NAME, gitignorePath);
|
|
109
|
-
}
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
110
95
|
logm.warn(`Could not write ${config.GITIGNORE_NAME} file: ${error.message}`);
|
|
111
96
|
}
|
|
112
97
|
}
|
|
113
98
|
}
|
|
99
|
+
//# sourceMappingURL=generate_gitignore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_gitignore.js","sourceRoot":"","sources":["../src/generate_gitignore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAGjC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,QAAkB,EAClB,UAAkB,EAClB,UAAiC,EAAE;IAEnC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE/B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,yCAAyC;IACzC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,qBAAqB,EAAE,CAAC;QAClD,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,MAAM,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAE9B,oCAAoC;IACpC,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9D,KAA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AC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAChC,mCAAmC;YACnC,UAAU,GAAG,CAAC,MAAM,CAAC,sBAAsB,EAAE,YAAY,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvG,CAAC;aAAM,CAAC;YACJ,wCAAwC;YACxC,MAAM,OAAO,GAAW,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC5D,UAAU,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,sBAAsB,EAAE,YAAY,EAAE,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CACrG,IAAI,CACP,CAAC;QACN,CAAC;IACL,CAAC;IAED,4BAA4B;IAC5B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;IACxE,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC;YACD,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,cAAc,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Lockfile, Jsonfile, Options, InitOptions, DependencyCategory, DependencyMap } from "./types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Normalize dependencies from the legacy array-of-strings format to the
|
|
4
|
+
* current versioned-object format. Passes through objects unchanged.
|
|
5
|
+
* @param dependencies - The raw dependencies object from modpack.json
|
|
6
|
+
* @returns Normalized dependencies with {@link DependencyMap} entries per category
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeDependencies(dependencies: Jsonfile["dependencies"] | null): Partial<Record<DependencyCategory, DependencyMap>>;
|
|
9
|
+
/**
|
|
10
|
+
* Generate a modpack.json file
|
|
11
|
+
* @param modpackInfo - The modpack information
|
|
12
|
+
* @param lockfile - The lockfile
|
|
13
|
+
* @param workingDir - The path to write the JSON object to
|
|
14
|
+
* @param options - The options object
|
|
15
|
+
* @returns The JSON file's object
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateJson(modpackInfo: Jsonfile, lockfile: Lockfile, workingDir: string, options?: Options | InitOptions): Promise<Jsonfile>;
|
|
18
|
+
//# sourceMappingURL=generate_json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate_json.d.ts","sourceRoot":"","sources":["../src/generate_json.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAElH;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,IAAI,GAC9C,OAAO,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC,CAmBpD;AAqBD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAC9B,WAAW,EAAE,QAAQ,EACrB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAO,GAAG,WAAgB,GACpC,OAAO,CAAC,QAAQ,CAAC,CAoFnB"}
|