@jtff/miztemplate-lib 3.0.0-rc19 → 3.0.0-rc20
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/lib/mizlib.js +4 -5
- package/package.json +1 -1
- package/scripts/inject-scripts.js +17 -9
package/lib/mizlib.js
CHANGED
|
@@ -19,7 +19,7 @@ class Mizlib {
|
|
|
19
19
|
for (let luaScript of luaScriptsArray) {
|
|
20
20
|
this.injectFileIntoZipObject(zipObject, [
|
|
21
21
|
workspacePath,
|
|
22
|
-
"/",
|
|
22
|
+
fromLibrary ? "/.workspace/" : "/",
|
|
23
23
|
folderPath,
|
|
24
24
|
"/",
|
|
25
25
|
path.basename(luaScript)
|
|
@@ -184,7 +184,8 @@ class Mizlib {
|
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
async injectMapResourceObjectIntoMizFile(mizPath, mapResourceObject) {
|
|
187
|
-
const zip =
|
|
187
|
+
const zip = await this.getZipObjectFromMizPath(mizPath);
|
|
188
|
+
this.injectMapResourceObjectIntoZipObject(zip, mapResourceObject);
|
|
188
189
|
const inputZip = await zip.generateAsync({
|
|
189
190
|
type: 'nodebuffer',
|
|
190
191
|
streamFiles: true,
|
|
@@ -212,7 +213,6 @@ class Mizlib {
|
|
|
212
213
|
.slice(0, -1)
|
|
213
214
|
.replace(/\[\"(\d+)\"\] = /g, "[$1] = ");
|
|
214
215
|
zip.file("mission", missionLuaT);
|
|
215
|
-
return zip;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
injectMapResourceObjectIntoZipObject(zip, mapResourceObject) {
|
|
@@ -225,7 +225,6 @@ class Mizlib {
|
|
|
225
225
|
.slice(0, -1)
|
|
226
226
|
.replace(/\[\"(\d+)\"\] = /g, "[$1] = ");
|
|
227
227
|
zip.file("l10n/DEFAULT/mapResource", mapResourceLuaT);
|
|
228
|
-
return zip;
|
|
229
228
|
}
|
|
230
229
|
|
|
231
230
|
getMissionLuaStringFromZipObject(zipStream) {
|
|
@@ -305,7 +304,7 @@ class Mizlib {
|
|
|
305
304
|
}
|
|
306
305
|
}
|
|
307
306
|
};
|
|
308
|
-
|
|
307
|
+
this.injectMissionObjectIntoZipObject(zip, {mission: mission_object});
|
|
309
308
|
}
|
|
310
309
|
|
|
311
310
|
injectSettingsLuaFilesFromFolderIntoZipObject(zip, strTheatre) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const prompt = require('prompt');
|
|
4
|
-
|
|
4
|
+
let _ = require('lodash');
|
|
5
5
|
|
|
6
6
|
function injectScripts(jtffci, env_mission) {
|
|
7
7
|
const workspacePath = [
|
|
@@ -474,7 +474,7 @@ function injectScripts(jtffci, env_mission) {
|
|
|
474
474
|
fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
|
|
475
475
|
fs.cpSync('node_modules/@jtff/miztemplate-lib/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
|
|
476
476
|
console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
|
|
477
|
-
|
|
477
|
+
await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
|
|
478
478
|
}
|
|
479
479
|
// traitement de la file d'attente des settings (injection des triggers et des fichiers lua)
|
|
480
480
|
if (settingsArray.length > 0) {
|
|
@@ -495,30 +495,38 @@ function injectScripts(jtffci, env_mission) {
|
|
|
495
495
|
mizObject = zipObject;
|
|
496
496
|
}
|
|
497
497
|
// réintégration du fichier mission dans l'archive
|
|
498
|
-
|
|
498
|
+
await jtffci.mizlib.injectMissionObjectIntoZipObject(
|
|
499
499
|
mizObject,
|
|
500
500
|
{ mission: missionObject }
|
|
501
501
|
);
|
|
502
|
-
|
|
502
|
+
await jtffci.mizlib.injectMapResourceObjectIntoZipObject(
|
|
503
503
|
mizObject,
|
|
504
504
|
{ mapResource: mapResourceObject }
|
|
505
505
|
);
|
|
506
506
|
// creation du fichier miz dans l'espace de travail
|
|
507
|
-
await fs.closeSync(fs.openSync(destinationMizFilePath, 'a'));
|
|
507
|
+
// await fs.closeSync(fs.openSync(destinationMizFilePath, 'a'));
|
|
508
508
|
// On fait une sauvegarde dans le folder de destination
|
|
509
|
-
|
|
509
|
+
fs.writeFileSync(destinationMizFilePath, await mizObject.generateAsync({
|
|
510
510
|
type: 'nodebuffer',
|
|
511
511
|
streamFiles: true,
|
|
512
512
|
compression: "DEFLATE",
|
|
513
513
|
compressionOptions: {
|
|
514
514
|
level: 9
|
|
515
515
|
}
|
|
516
|
-
});
|
|
517
|
-
fs.writeFileSync(destinationMizFilePath, inputZip);
|
|
518
|
-
// generation des outils CI JTFF
|
|
516
|
+
}));
|
|
519
517
|
await jtffci.deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, env_mission);
|
|
520
518
|
console.log('...Done...');
|
|
521
519
|
return 0;
|
|
520
|
+
// fs.writeFileSync(destinationMizFilePath, inputZip);
|
|
521
|
+
// await fs.createWriteStream(destinationMizFilePath, await mizObject.generateNodeStream({
|
|
522
|
+
// type: 'nodebuffer',
|
|
523
|
+
// streamFiles: true,
|
|
524
|
+
// compression: "DEFLATE",
|
|
525
|
+
// compressionOptions: {
|
|
526
|
+
// level: 9
|
|
527
|
+
// }
|
|
528
|
+
// }));
|
|
529
|
+
// generation des outils CI JTFF
|
|
522
530
|
});
|
|
523
531
|
}
|
|
524
532
|
|