cyclops-infobook-html 2.0.0 → 3.0.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/CHANGELOG.md +6 -0
- package/bin/generate-infobook-html.js +1 -1
- package/index.js +8 -0
- package/lib/infobook/FileWriter.js +1 -0
- package/lib/infobook/InfoBookInitializer.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixAd.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe.js +2 -1
- package/lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerImage.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerKeybinding.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe.js +1 -0
- package/lib/infobook/appendix/InfoBookAppendixTagIndex.js +1 -0
- package/lib/modloader/ModLoader.js +12 -5
- package/lib/parse/XmlInfoBookParser.js +1 -0
- package/lib/resource/ResourceHandler.js +2 -1
- package/lib/resource/ResourceLoader.js +1 -0
- package/lib/serialize/HtmlInfoBookSerializer.js +11 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
<a name="v3.0.0"></a>
|
|
5
|
+
## [v3.0.0](https://github.com/CyclopsMC/infobook-html/compare/v2.0.0...v3.0.0) - 2022-03-10
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
* [Update to MC 1.18](https://github.com/CyclopsMC/infobook-html/commit/1fb77959593a2b84cb14e56406f0df20ad450e16)
|
|
9
|
+
|
|
4
10
|
<a name="v2.0.0"></a>
|
|
5
11
|
## [v2.0.0](https://github.com/CyclopsMC/infobook-html/compare/v1.1.2...v2.0.0) - 2021-02-03
|
|
6
12
|
|
|
@@ -88,7 +88,7 @@ function create() {
|
|
|
88
88
|
path += '/';
|
|
89
89
|
}
|
|
90
90
|
const infoBookSerializer = new HtmlInfoBookSerializer_1.HtmlInfoBookSerializer();
|
|
91
|
-
yield infoBookSerializer.serialize(infoBook, Object.assign({}, config, { headSuffixGetters,
|
|
91
|
+
yield infoBookSerializer.serialize(infoBook, Object.assign(Object.assign({}, config), { headSuffixGetters,
|
|
92
92
|
mods,
|
|
93
93
|
path, resourceHandler: resourceLoader.getResourceHandler(), root: true }), assetsPaths);
|
|
94
94
|
});
|
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/infobook/appendix/IInfoBookAppendixHandler"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixAd"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards"), exports);
|
|
@@ -10,6 +11,13 @@ tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerIma
|
|
|
10
11
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixHandlerKeybinding"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./lib/infobook/appendix/InfoBookAppendixTagIndex"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./lib/infobook/FileWriter"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./lib/infobook/IFileWriter"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./lib/infobook/IFluid"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfoAppendix"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfoBook"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfobookPlugin"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./lib/infobook/IInfoSection"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./lib/infobook/IItem"), exports);
|
|
13
21
|
tslib_1.__exportStar(require("./lib/infobook/InfoBookInitializer"), exports);
|
|
14
22
|
tslib_1.__exportStar(require("./lib/modloader/ModLoader"), exports);
|
|
15
23
|
tslib_1.__exportStar(require("./lib/parse/XmlInfoBookParser"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookInitializer = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const XmlInfoBookParser_1 = require("../parse/XmlInfoBookParser");
|
|
5
6
|
const InfoBookAppendixTagIndex_1 = require("./appendix/InfoBookAppendixTagIndex");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixHandlerAbstractRecipe = void 0;
|
|
3
4
|
const fs = require("fs");
|
|
4
5
|
const path_1 = require("path");
|
|
5
6
|
/**
|
|
@@ -11,7 +12,7 @@ class InfoBookAppendixHandlerAbstractRecipe {
|
|
|
11
12
|
this.resourceHandler = resourceHandler;
|
|
12
13
|
this.registry = InfoBookAppendixHandlerAbstractRecipe.indexRegistry(JSON.parse(fs.readFileSync(path_1.join(registriesPath, id.replace(/:/g, '__') + '.json'), "utf8")));
|
|
13
14
|
if (recipeOverrides) {
|
|
14
|
-
this.registry = Object.assign({}, this.registry, (recipeOverrides[id] || {}));
|
|
15
|
+
this.registry = Object.assign(Object.assign({}, this.registry), (recipeOverrides[id] || {}));
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
static indexRegistry(registryRead) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixHandlerCraftingRecipe = void 0;
|
|
3
4
|
const pug_1 = require("pug");
|
|
4
5
|
const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandlerAbstractRecipe");
|
|
5
6
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InfoBookAppendixHandlerSmeltingRecipe = void 0;
|
|
3
4
|
const pug_1 = require("pug");
|
|
4
5
|
const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandlerAbstractRecipe");
|
|
5
6
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModLoader = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const child_process_1 = require("child_process");
|
|
5
6
|
const fs_1 = require("fs");
|
|
@@ -11,6 +12,7 @@ const path_1 = require("path");
|
|
|
11
12
|
const rimraf = require("rimraf");
|
|
12
13
|
const util_1 = require("util");
|
|
13
14
|
const yauzl_1 = require("yauzl");
|
|
15
|
+
const Path = require("path");
|
|
14
16
|
/**
|
|
15
17
|
* Takes care of installing Forge, installing mods, starting a Forge server, and fetching metadata.
|
|
16
18
|
*/
|
|
@@ -117,7 +119,7 @@ class ModLoader {
|
|
|
117
119
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
118
120
|
// Start the Forge server
|
|
119
121
|
process.stdout.write('Starting server...\n');
|
|
120
|
-
const proc = child_process_1.exec(`cd ${this.path} &&
|
|
122
|
+
const proc = child_process_1.exec(`cd ${this.path} && ./run.sh nogui`);
|
|
121
123
|
// Ignore stdout: proc.stdout.pipe(process.stdout);
|
|
122
124
|
proc.stderr.pipe(process.stderr);
|
|
123
125
|
const onDone = new Promise((resolve, reject) => {
|
|
@@ -133,7 +135,7 @@ class ModLoader {
|
|
|
133
135
|
});
|
|
134
136
|
// Once the loading is complete, send our command and stop the server
|
|
135
137
|
proc.stdout.on('data', (line) => {
|
|
136
|
-
if (line.indexOf('[
|
|
138
|
+
if (line.indexOf('[Server thread/INFO]: Done') >= 0) {
|
|
137
139
|
process.stdout.write('Dumping registries...\n');
|
|
138
140
|
this.sendCommand(proc, '/cyclopscore dumpregistries');
|
|
139
141
|
this.sendCommand(proc, '/stop');
|
|
@@ -174,9 +176,14 @@ class ModLoader {
|
|
|
174
176
|
}
|
|
175
177
|
// Find Minecraft jar
|
|
176
178
|
let jar = null;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
const subPath = Path.join(this.path, 'libraries', 'net', 'minecraft', 'server');
|
|
180
|
+
for (const dir of yield fs.promises.readdir(subPath)) {
|
|
181
|
+
if (dir.indexOf('-') > 0) {
|
|
182
|
+
for (const file of yield fs.promises.readdir(Path.join(subPath, dir))) {
|
|
183
|
+
if (file.startsWith('server') && file.endsWith('extra.jar')) {
|
|
184
|
+
jar = path_1.join(subPath, dir, file);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
189
|
// Error if no jar was found
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceHandler = void 0;
|
|
3
4
|
const path_1 = require("path");
|
|
4
5
|
/**
|
|
5
6
|
* Allows Minecraft resources to be used.
|
|
@@ -252,9 +253,9 @@ class ResourceHandler {
|
|
|
252
253
|
return keybinding;
|
|
253
254
|
}
|
|
254
255
|
}
|
|
256
|
+
exports.ResourceHandler = ResourceHandler;
|
|
255
257
|
ResourceHandler.TRANSLATION_DEFAULTS = {
|
|
256
258
|
'fluid.tile.lava': 'Lava',
|
|
257
259
|
'fluid.tile.water': 'Water',
|
|
258
260
|
};
|
|
259
|
-
exports.ResourceHandler = ResourceHandler;
|
|
260
261
|
//# sourceMappingURL=ResourceHandler.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HtmlInfoBookSerializer = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const fs_1 = require("fs");
|
|
5
6
|
const mkdirp = require("mkdirp");
|
|
@@ -21,7 +22,7 @@ class HtmlInfoBookSerializer {
|
|
|
21
22
|
}
|
|
22
23
|
serialize(infobook, context, assetsPaths) {
|
|
23
24
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
context = Object.assign({}, context, { basePath: context.path, breadcrumbs: [] });
|
|
25
|
+
context = Object.assign(Object.assign({}, context), { basePath: context.path, breadcrumbs: [] });
|
|
25
26
|
this.fileWriter = new FileWriter_1.FileWriter(context);
|
|
26
27
|
yield this.ensureDirExists(context.path);
|
|
27
28
|
yield this.ensureDirExists(path_1.join(context.path, 'assets'));
|
|
@@ -50,7 +51,7 @@ class HtmlInfoBookSerializer {
|
|
|
50
51
|
urlIndex: {},
|
|
51
52
|
};
|
|
52
53
|
let pageIndex = 0;
|
|
53
|
-
yield this.serializeSection(infobook.rootSection, Object.assign({}, contextRoot, { language, path: langPath }), ({ index, section, sectionTitle, fileUrl, breadcrumbs }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath }), ({ index, section, sectionTitle, fileUrl, breadcrumbs }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
if (!index) {
|
|
55
56
|
sectionIndex.urlIndex[fileUrl] = pageIndex++;
|
|
56
57
|
const name = breadcrumbs.slice(1).map((b) => b.name).join(' / ');
|
|
@@ -68,7 +69,7 @@ class HtmlInfoBookSerializer {
|
|
|
68
69
|
}
|
|
69
70
|
serializeSectionFiles(infobook, contextRoot, language, langPath, sectionIndex) {
|
|
70
71
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
yield this.serializeSection(infobook.rootSection, Object.assign({}, contextRoot, { language, path: langPath, sectionIndex }), ({ index, breadcrumbs, context, section, sectionTitle, subSectionDatas, filePath, fileUrl }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath, sectionIndex }), ({ index, breadcrumbs, context, section, sectionTitle, subSectionDatas, filePath, fileUrl }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
72
73
|
// Create links to this page in other languages
|
|
73
74
|
const languages = [];
|
|
74
75
|
for (const name of contextRoot.resourceHandler.getLanguages()) {
|
|
@@ -79,7 +80,7 @@ class HtmlInfoBookSerializer {
|
|
|
79
80
|
}
|
|
80
81
|
if (index) {
|
|
81
82
|
// Create index file
|
|
82
|
-
const fileContents = this.templateIndex(Object.assign({}, context, { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
83
|
+
const fileContents = this.templateIndex(Object.assign(Object.assign({}, context), { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
83
84
|
sectionTitle,
|
|
84
85
|
subSectionDatas }));
|
|
85
86
|
yield fs_1.promises.writeFile(filePath, fileContents);
|
|
@@ -97,7 +98,7 @@ class HtmlInfoBookSerializer {
|
|
|
97
98
|
appendices.unshift(new InfoBookAppendixAd_1.InfoBookAppendixAd());
|
|
98
99
|
}
|
|
99
100
|
// Create leaf file
|
|
100
|
-
const fileContents = this.templateSection(Object.assign({}, context, { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
101
|
+
const fileContents = this.templateSection(Object.assign(Object.assign({}, context), { breadcrumbs, headSuffix: context.headSuffixGetters.map((g) => g(context)).join(''), languages,
|
|
101
102
|
nextPage,
|
|
102
103
|
previousPage, sectionAppendices: appendices
|
|
103
104
|
.filter((appendix) => appendix) // TODO: rm
|
|
@@ -128,7 +129,7 @@ class HtmlInfoBookSerializer {
|
|
|
128
129
|
// Go in a subfolder when we are handling a different mod
|
|
129
130
|
if (section.modId !== context.modId) {
|
|
130
131
|
yield this.ensureDirExists(path_1.join(context.path, section.modId));
|
|
131
|
-
context = Object.assign({}, context, { modId: section.modId, path: path_1.join(context.path, section.modId) });
|
|
132
|
+
context = Object.assign(Object.assign({}, context), { modId: section.modId, path: path_1.join(context.path, section.modId) });
|
|
132
133
|
}
|
|
133
134
|
if (section.subSections && section.subSections.length > 0) {
|
|
134
135
|
// Navigation section
|
|
@@ -140,9 +141,9 @@ class HtmlInfoBookSerializer {
|
|
|
140
141
|
url: fileUrl,
|
|
141
142
|
}]);
|
|
142
143
|
for (const subSection of section.subSections) {
|
|
143
|
-
const subSectionData = yield this.serializeSection(subSection, Object.assign({}, context, { breadcrumbs: subBreadcrumbs, path: path_1.join(context.path, subSection.nameTranslationKey
|
|
144
|
+
const subSectionData = yield this.serializeSection(subSection, Object.assign(Object.assign({}, context), { breadcrumbs: subBreadcrumbs, path: path_1.join(context.path, subSection.nameTranslationKey
|
|
144
145
|
.substr(subSection.nameTranslationKey.lastIndexOf('.') + 1)), root: false }), onSection);
|
|
145
|
-
subSectionDatas.push(Object.assign({}, subSectionData, { url: this.filePathToUrl(subSectionData.filePath, context.basePath, context.baseUrl) }));
|
|
146
|
+
subSectionDatas.push(Object.assign(Object.assign({}, subSectionData), { url: this.filePathToUrl(subSectionData.filePath, context.basePath, context.baseUrl) }));
|
|
146
147
|
}
|
|
147
148
|
const filePath = path_1.join(context.path, 'index.html');
|
|
148
149
|
yield onSection({ index: true, breadcrumbs, context, sectionTitle, section, subSectionDatas, filePath, fileUrl });
|
|
@@ -186,7 +187,7 @@ class HtmlInfoBookSerializer {
|
|
|
186
187
|
throw new Error(`Could not find translation key for item ${JSON.stringify(item)}`);
|
|
187
188
|
}
|
|
188
189
|
const { link, linkTarget } = this.createResourceLink(resourceHandler, context, item.item, key);
|
|
189
|
-
return this.templateItem(Object.assign({}, context, { annotation, count: item.count || 1, icon: iconUrl, link,
|
|
190
|
+
return this.templateItem(Object.assign(Object.assign({}, context), { annotation, count: item.count || 1, icon: iconUrl, link,
|
|
190
191
|
linkTarget, name: resourceHandler.getTranslation(resourceHandler.getItemTranslationKey(item), context.language), slot }));
|
|
191
192
|
}
|
|
192
193
|
createFluidDisplay(resourceHandler, context, fileWriter, fluid, slot) {
|
|
@@ -200,7 +201,7 @@ class HtmlInfoBookSerializer {
|
|
|
200
201
|
throw new Error(`Could not find translation key for fluid ${JSON.stringify(fluid)}`);
|
|
201
202
|
}
|
|
202
203
|
const { link, linkTarget } = this.createResourceLink(resourceHandler, context, this.tagFluid(context, fluid.fluid), key);
|
|
203
|
-
return this.templateItem(Object.assign({}, context, { count: (fluid.amount || 1), icon: iconUrl, link,
|
|
204
|
+
return this.templateItem(Object.assign(Object.assign({}, context), { count: (fluid.amount || 1), icon: iconUrl, link,
|
|
204
205
|
linkTarget, name: resourceHandler.getTranslation(resourceHandler.getFluidTranslationKey(fluid), context.language), slot }));
|
|
205
206
|
}
|
|
206
207
|
tagFluid(context, fluidName) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyclops-infobook-html",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Output Cyclops infobooks as HTML",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "git@github.com:CyclopsMC/infobook-html.git",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"ts-jest": "^26.0.0",
|
|
60
60
|
"tslint": "^6.0.0",
|
|
61
61
|
"tslint-eslint-rules": "^5.4.0",
|
|
62
|
-
"typescript": "^
|
|
62
|
+
"typescript": "^4.0.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"test": "jest ${1}",
|