@jtff/miztemplate-lib 3.0.0-rc17 → 3.0.0-rc19

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.
@@ -249,7 +249,7 @@ class MizTemplateCI{
249
249
  }
250
250
 
251
251
  async InjectCiScriptsIntoWorkspace(workspacePath) {
252
- fs.cpSync('node_modules/@jtff/miztemplate-lib/ci',workspacePath + '/src/nodejs',{recursive: true});
252
+ fs.cpSync('node_modules/@jtff/miztemplate-lib/ci',workspacePath + '/.workspace/src/nodejs',{recursive: true});
253
253
  }
254
254
 
255
255
  async deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, mizFilePath) {
package/lib/mizlib.js CHANGED
@@ -12,10 +12,10 @@ class Mizlib {
12
12
  // no need for initialization
13
13
  }
14
14
 
15
- async injectLuaScriptIntoZipObjectAndUpdateWorkspace(workspacePath, folderPath, luaScriptsArray, titleString, zipObject, timing, colorString) {
15
+ async injectLuaScriptIntoZipObjectAndUpdateWorkspace(workspacePath, folderPath, luaScriptsArray, titleString, zipObject, timing, colorString, fromLibrary=true) {
16
16
  let missionObject = await this.getMissionObjectFromZipObject(zipObject);
17
17
  let mapResourceObject = await this.getMapResourceObjectFromZipObject(zipObject);
18
- let tuple = this.injectLuaScriptAndUpdateWorkspace(workspacePath, folderPath, luaScriptsArray, titleString, missionObject, mapResourceObject, timing, colorString);
18
+ let tuple = this.injectLuaScriptAndUpdateWorkspace(workspacePath, folderPath, luaScriptsArray, titleString, missionObject, mapResourceObject, timing, colorString, fromLibrary);
19
19
  for (let luaScript of luaScriptsArray) {
20
20
  this.injectFileIntoZipObject(zipObject, [
21
21
  workspacePath,
@@ -29,7 +29,7 @@ class Mizlib {
29
29
  return {tuple, zipObject};
30
30
  }
31
31
 
32
- injectLuaScriptAndUpdateWorkspace(workspacePath, folderPath, luaScriptsArray, titleString, missionObject, mapResourceObject, timing, colorString) {
32
+ injectLuaScriptAndUpdateWorkspace(workspacePath, folderPath, luaScriptsArray, titleString, missionObject, mapResourceObject, timing, colorString ,fromLibrary=true) {
33
33
  let tuple = this.injectLuaScriptsInMissionObject(
34
34
  missionObject['trig'],
35
35
  missionObject['trigrules'],
@@ -40,7 +40,7 @@ class Mizlib {
40
40
  colorString
41
41
  );
42
42
  for (let luaScript of luaScriptsArray) {
43
- fs.copyFileSync(
43
+ fs.cpSync(
44
44
  [
45
45
  'node_modules/@jtff/miztemplate-lib/lua/',
46
46
  folderPath,
@@ -49,11 +49,12 @@ class Mizlib {
49
49
  ].join(""),
50
50
  [
51
51
  workspacePath,
52
- "/",
52
+ fromLibrary ? "/.workspace/" : "/",
53
53
  folderPath,
54
54
  "/",
55
55
  path.basename(luaScript)
56
- ].join("")
56
+ ].join(""),
57
+ {force: true}
57
58
  );
58
59
  }
59
60
  return tuple;
@@ -131,7 +132,7 @@ class Mizlib {
131
132
  }
132
133
  this.injectLuaFilesFromFolderIntoZipObject(zipObject, 'src');
133
134
  this.injectLuaFilesFromFolderIntoZipObject(zipObject, 'lib');
134
- await this.injectRadioPresetsFromFolderIntoZipObject(zipObject, 'resources/radios/' + strTheatreSettings);
135
+ zipObject = await this.injectRadioPresetsFromFolderIntoZipObject(zipObject, 'resources/radios/' + strTheatreSettings);
135
136
  this.injectSettingsLuaFilesFromFolderIntoZipObject(zipObject, singleMission ? '' : strTheatreSettings);
136
137
  await this.injectSoundFoldersIntoZipObject(zipObject);
137
138
  const inputZip = await zipObject.generateAsync({
@@ -145,9 +146,8 @@ class Mizlib {
145
146
  fs.writeFileSync(copyPath ? copyPath : mizPath, inputZip);
146
147
  }
147
148
 
148
- async mizInjectMissionDataFile(mizPath, missionObject) {
149
- const zip = await this.getZipObjectFromMizPath(mizPath);
150
- this.mizUpdateMissionDataFile(zip, missionObject);
149
+ async injectMissionObjectIntoMizFile(mizPath, missionObject) {
150
+ const zip = this.injectMissionObjectIntoZipObject(await this.getZipObjectFromMizPath(mizPath), missionObject);
151
151
  const inputZip = await zip.generateAsync({
152
152
  type: 'nodebuffer',
153
153
  streamFiles: true,
@@ -183,9 +183,8 @@ class Mizlib {
183
183
  }
184
184
 
185
185
 
186
- async mizInjectMapResourceFile(mizPath, mapResourceObject) {
187
- const zip = await this.getZipObjectFromMizPath(mizPath);
188
- this.mizUpdateMapResourceFile(zip, mapResourceObject);
186
+ async injectMapResourceObjectIntoMizFile(mizPath, mapResourceObject) {
187
+ const zip = this.injectMapResourceObjectIntoZipObject(await this.getZipObjectFromMizPath(mizPath), mapResourceObject);
189
188
  const inputZip = await zip.generateAsync({
190
189
  type: 'nodebuffer',
191
190
  streamFiles: true,
@@ -203,7 +202,7 @@ class Mizlib {
203
202
  zip.file("l10n/DEFAULT/" + path.basename(filePath), stream);
204
203
  }
205
204
 
206
- mizUpdateMissionDataFile(zip, missionObject) {
205
+ injectMissionObjectIntoZipObject(zip, missionObject) {
207
206
  zip.remove("mission");
208
207
  let missionLuaT = format(missionObject, {singleQuote: false})
209
208
  missionLuaT = missionLuaT
@@ -213,9 +212,10 @@ class Mizlib {
213
212
  .slice(0, -1)
214
213
  .replace(/\[\"(\d+)\"\] = /g, "[$1] = ");
215
214
  zip.file("mission", missionLuaT);
215
+ return zip;
216
216
  }
217
217
 
218
- mizUpdateMapResourceFile(zip, mapResourceObject) {
218
+ injectMapResourceObjectIntoZipObject(zip, mapResourceObject) {
219
219
  zip.remove("l10n/DEFAULT/mapResource");
220
220
  let mapResourceLuaT = format(mapResourceObject, {singleQuote: false})
221
221
  mapResourceLuaT = mapResourceLuaT
@@ -225,6 +225,7 @@ class Mizlib {
225
225
  .slice(0, -1)
226
226
  .replace(/\[\"(\d+)\"\] = /g, "[$1] = ");
227
227
  zip.file("l10n/DEFAULT/mapResource", mapResourceLuaT);
228
+ return zip;
228
229
  }
229
230
 
230
231
  getMissionLuaStringFromZipObject(zipStream) {
@@ -304,7 +305,7 @@ class Mizlib {
304
305
  }
305
306
  }
306
307
  };
307
- this.mizUpdateMissionDataFile(zip, {mission: mission_object});
308
+ return this.injectMissionObjectIntoZipObject(zip, {mission: mission_object});
308
309
  }
309
310
 
310
311
  injectSettingsLuaFilesFromFolderIntoZipObject(zip, strTheatre) {
@@ -328,41 +329,48 @@ class Mizlib {
328
329
  fs.existsSync(
329
330
  [
330
331
  workspacePath,
331
- "/resources/sounds/",
332
+ "/.workspace/resources/sounds/",
332
333
  folderString
333
334
  ].join("")
334
335
  ) &&
335
336
  fs.lstatSync([
336
337
  workspacePath,
337
- "/resources/sounds/",
338
+ "/.workspace/resources/sounds/",
338
339
  folderString
339
340
  ].join("")).isDirectory()
340
341
  ) {
341
342
  fs.rmSync([
342
343
  workspacePath,
343
- "/resources/sounds/",
344
+ "/.workspace/resources/sounds/",
344
345
  folderString
345
346
  ].join(""), {recursive: true});
346
347
  }
347
- if (fs.existsSync('node_modules/@jtff/miztemplate-lib/resources/sounds/' + folderString) && fs.lstatSync('node_modules/@jtff/miztemplate-lib/resources/sounds/' + folderString).isDirectory()) {
348
+ if (
349
+ fs.existsSync('node_modules/@jtff/miztemplate-lib/resources/sounds/' + folderString) &&
350
+ fs.lstatSync('node_modules/@jtff/miztemplate-lib/resources/sounds/' + folderString).isDirectory()) {
348
351
  fs.mkdirSync([
349
352
  workspacePath,
350
- "/resources/sounds/",
353
+ "/.workspace/resources/sounds/",
351
354
  folderString
352
355
  ].join(""), {recursive: true});
353
356
  fs.cpSync('node_modules/@jtff/miztemplate-lib/resources/sounds/' + folderString,[
354
357
  workspacePath,
355
- "/resources/sounds/",
358
+ "/.workspace/resources/sounds/",
356
359
  folderString
357
360
  ].join(""), {recursive: true});
358
361
  }
359
362
  }
360
363
 
361
- async injectSingleSoundFolderIntoZipObject(zip, workspacePath, folder) {
362
- if (fs.existsSync(workspacePath + '/resources/sounds/' + folder) && fs.lstatSync(workspacePath + '/resources/sounds/' + folder).isDirectory()) {
363
- console.log('adding sound files from '+workspacePath+'/resources/sounds/' + folder + ' folder...');
364
+ async injectSingleSoundFolderIntoZipObject(zip, workspacePath, folder, fromLibrary = true) {
365
+ if (
366
+ fs.existsSync([workspacePath,fromLibrary? '/.workspace/resources/sounds/' : '/resources/sounds/',folder].join('')) &&
367
+ fs.lstatSync([workspacePath,fromLibrary? '/.workspace/resources/sounds/' : '/resources/sounds/',folder].join('')).isDirectory()) {
368
+ console.log(['adding sound files from ',workspacePath,fromLibrary? '/.workspace/resources/sounds/' : '/resources/sounds/',folder,' folder...'].join(''));
364
369
  zip = zip.remove(folder).folder(folder);
365
- await this.addFilesToZip(zip, workspacePath + '/resources/sounds/' + folder, fs.readdirSync(workspacePath + '/resources/sounds/' + folder));
370
+ await this.addFilesToZip(
371
+ zip,
372
+ [workspacePath,fromLibrary? '/.workspace/resources/sounds/' : '/resources/sounds/',folder].join(''),
373
+ fs.readdirSync([workspacePath,fromLibrary? '/.workspace/resources/sounds/' : '/resources/sounds/',folder].join('')));
366
374
  }
367
375
  }
368
376
 
@@ -409,7 +417,13 @@ class Mizlib {
409
417
 
410
418
  async getMapResourceObjectFromZipObject(zip) {
411
419
  let luaTable = 'return { \n' + await this.getMapResourceLuaStringFromZipObject(zip) + ' }';
412
- return parse(luaTable).mapResource;
420
+ let mrObject = parse(luaTable).mapResource;
421
+ if (Array.isArray(mrObject)) {
422
+ if (mrObject.length === 0) {
423
+ mrObject = {};
424
+ }
425
+ }
426
+ return mrObject;
413
427
  }
414
428
  }
415
429
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtff/miztemplate-lib",
3
- "version": "3.0.0-rc17",
3
+ "version": "3.0.0-rc19",
4
4
  "description": "JTFF mission template library",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -34,6 +34,7 @@
34
34
  "ftp": "^0.3.10",
35
35
  "googleapis": "^92.0.0",
36
36
  "jszip": "^3.10.1",
37
+ "lodash": "^4.17.21",
37
38
  "lua-json": "^1.0.1",
38
39
  "path": "^0.12.7",
39
40
  "prompt": "^1.3.0",
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require("path");
3
3
  const prompt = require('prompt');
4
+ var _ = require('lodash');
4
5
 
5
6
  function injectScripts(jtffci, env_mission) {
6
7
  const workspacePath = [
@@ -29,21 +30,33 @@ function injectScripts(jtffci, env_mission) {
29
30
  // create a src folder
30
31
  fs.mkdirSync([
31
32
  workspacePath,
32
- "/src"
33
+ "/.workspace/src"
33
34
  ].join(""),
34
35
  { recursive: true }
35
36
  );
36
37
  // create a lib folder
37
38
  fs.mkdirSync([
38
39
  workspacePath,
39
- "/lib"
40
+ "/.workspace/lib"
40
41
  ].join(""),
41
42
  { recursive: true }
42
43
  );
43
44
  // create a resources folder
44
45
  fs.mkdirSync([
45
46
  workspacePath,
46
- "/resources"
47
+ "/.workspace/resources/sounds"
48
+ ].join(""),
49
+ { recursive: true }
50
+ );
51
+ fs.mkdirSync([
52
+ workspacePath,
53
+ "/resources/radios"
54
+ ].join(""),
55
+ { recursive: true }
56
+ );
57
+ fs.mkdirSync([
58
+ workspacePath,
59
+ "/resources/sounds"
47
60
  ].join(""),
48
61
  { recursive: true }
49
62
  );
@@ -138,11 +151,6 @@ function injectScripts(jtffci, env_mission) {
138
151
  let settingsArray = [];
139
152
  let scriptsArray = [];
140
153
  let libsArray = [];
141
- if (Array.isArray(mapResourceObject)) {
142
- if (mapResourceObject.length === 0) {
143
- mapResourceObject = {};
144
- }
145
- }
146
154
  // insertion des librairies externes dans la file d'attente
147
155
  libsArray.push({
148
156
  folder: 'lib',
@@ -181,10 +189,10 @@ function injectScripts(jtffci, env_mission) {
181
189
  });
182
190
  // injection des fichiers son Généraux si repertoire resources/sounds/General present
183
191
  await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'General');
184
- await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'General');
192
+ await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'General', true);
185
193
  // injection des fichiers son Misc si repertoire resources/sounds/Misc present
186
194
  await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'Misc');
187
- await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'Misc');
195
+ await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'Misc', true);
188
196
  // insertion des Librairies JTFF dans la file d'attente
189
197
  settingsArray.push(
190
198
  {
@@ -209,20 +217,21 @@ function injectScripts(jtffci, env_mission) {
209
217
  color: '0xffff00ff'
210
218
  });
211
219
  // traitement de la file d'attente des librairies (injection des triggers et des fichiers lua)
212
- for ( script of libsArray) {
213
- console.log(['adding library',script.scripts.join(' and '),'from',workspacePath + '/' + script.folder, 'folder...'].join(' '));
220
+ for ( libscript of libsArray) {
221
+ console.log(['adding library',libscript.scripts.join(' and '),'from',workspacePath + '/.workspace/' + libscript.folder, 'folder...'].join(' '));
214
222
  let {tuple, zipObject} = await jtffci.mizlib.injectLuaScriptIntoZipObjectAndUpdateWorkspace(
215
223
  workspacePath,
216
- script.folder,
217
- script.scripts,
218
- script.scriptTitle + ' Load',
224
+ libscript.folder,
225
+ libscript.scripts,
226
+ libscript.scriptTitle + ' Load',
219
227
  mizObject,
220
- script.timing,
221
- script.color
228
+ libscript.timing,
229
+ libscript.color,
230
+ true
222
231
  );
223
232
  missionObject['trig'] = tuple.tObject;
224
233
  missionObject['trigrules'] = tuple.trObject;
225
- mapResourceObject = tuple.mrObject;
234
+ mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
226
235
  mizObject = zipObject;
227
236
  }
228
237
  // injection de la gestion des Set_Clients dans la file d'attente
@@ -231,7 +240,8 @@ function injectScripts(jtffci, env_mission) {
231
240
  scriptTitle: 'Set clients',
232
241
  scripts: ['110-set_clients.lua'],
233
242
  timing: 21,
234
- color: '0xff0000ff'
243
+ color: '0xff0000ff',
244
+ fromLibrary: true
235
245
  });
236
246
  // injection des Tankers et OndemandTankers dans la file d'attente
237
247
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_tankers)) {
@@ -250,14 +260,15 @@ function injectScripts(jtffci, env_mission) {
250
260
  scriptTitle: 'Tankers',
251
261
  scripts: ['120-tankers.lua'],
252
262
  timing: 22,
253
- color: '0xff0000ff'
263
+ color: '0xff0000ff',
264
+ fromLibrary: true
254
265
  });
255
266
  }
256
267
  // injection des Airboss et Pedros dans la file d'attente
257
268
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_airboss)) {
258
269
  // injection des fichiers son Airboss
259
270
  await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'AIRBOSS');
260
- await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'AIRBOSS');
271
+ await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'AIRBOSS', true);
261
272
  settingsArray.push(
262
273
  {
263
274
  file: "settings-airboss.lua",
@@ -273,7 +284,8 @@ function injectScripts(jtffci, env_mission) {
273
284
  scriptTitle: 'Airboss',
274
285
  scripts: ['130-airboss.lua', '135-pedro.lua'],
275
286
  timing: 23,
276
- color: '0xff0000ff'
287
+ color: '0xff0000ff',
288
+ fromLibrary: true
277
289
  });
278
290
  }
279
291
  // injection des Beacons dans la file d'attente
@@ -289,7 +301,8 @@ function injectScripts(jtffci, env_mission) {
289
301
  scriptTitle: 'Beacons',
290
302
  scripts: ['140-beacons.lua'],
291
303
  timing: 24,
292
- color: '0xff0000ff'
304
+ color: '0xff0000ff',
305
+ fromLibrary: true
293
306
  });
294
307
  }
295
308
  // injection des AWACS et OnDemandAwacs dans la file d'attente
@@ -309,14 +322,15 @@ function injectScripts(jtffci, env_mission) {
309
322
  scriptTitle: 'Awacs',
310
323
  scripts: ['150-awacs.lua'],
311
324
  timing: 25,
312
- color: '0xff0000ff'
325
+ color: '0xff0000ff',
326
+ fromLibrary: true
313
327
  });
314
328
  }
315
329
  // injection des ATIS dans la file d'attente
316
330
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_atis)) {
317
331
  // injection des fichiers son ATIS
318
332
  await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'ATIS');
319
- await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'ATIS');
333
+ await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'ATIS', true);
320
334
  settingsArray.push(
321
335
  {
322
336
  file: "settings-atis.lua",
@@ -328,7 +342,8 @@ function injectScripts(jtffci, env_mission) {
328
342
  scriptTitle: 'ATIS',
329
343
  scripts: ['160-atis.lua'],
330
344
  timing: 26,
331
- color: '0xff0000ff'
345
+ color: '0xff0000ff',
346
+ fromLibrary: true
332
347
  });
333
348
  }
334
349
  // injection des scripts A2A dans la file d'attente
@@ -360,14 +375,15 @@ function injectScripts(jtffci, env_mission) {
360
375
  scriptTitle: 'Air To Air',
361
376
  scripts: ['170-cap_zone_training.lua', '172-cap_zone_war.lua', '173-fox_zone_training.lua', '176-random_air_traffic.lua', '178-training-intercept.lua'],
362
377
  timing: 27,
363
- color: '0xff0000ff'
378
+ color: '0xff0000ff',
379
+ fromLibrary: true
364
380
  });
365
381
  }
366
382
  // injection des CTLD dans la file d'attente
367
383
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_Logistics)) {
368
384
  // injection des fichiers son CTLD
369
385
  await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'CTLD');
370
- await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'CTLD');
386
+ await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'CTLD', true);
371
387
  settingsArray.push(
372
388
  {
373
389
  file: "settings-logistics.lua",
@@ -379,14 +395,15 @@ function injectScripts(jtffci, env_mission) {
379
395
  scriptTitle: 'Logistics',
380
396
  scripts: ['180-logistics.lua'],
381
397
  timing: 28,
382
- color: '0xff0000ff'
398
+ color: '0xff0000ff',
399
+ fromLibrary: true
383
400
  });
384
401
  }
385
402
  // injection des scripts A2G dans la file d'attente
386
403
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_A2G)) {
387
404
  // injection des fichiers son Range
388
405
  await jtffci.mizlib.updateWorkspaceWithSingleSoundFolder(workspacePath, 'RANGE');
389
- await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'RANGE');
406
+ await jtffci.mizlib.injectSingleSoundFolderIntoZipObject(mizObject,workspacePath, 'RANGE', true);
390
407
  settingsArray.push(
391
408
  {
392
409
  file: "settings-ranges.lua",
@@ -418,7 +435,8 @@ function injectScripts(jtffci, env_mission) {
418
435
  scriptTitle: 'Air To Ground',
419
436
  scripts: ['190-ranges.lua', '191-sams.lua', '193-training_ranges.lua', '195-reaper-ondemand.lua', '196-fac_ranges.lua', '199-skynet.lua'],
420
437
  timing: 29,
421
- color: '0xff0000ff'
438
+ color: '0xff0000ff',
439
+ fromLibrary: true
422
440
  });
423
441
  }
424
442
  // injection du script spécifique de mission dans la file d'attente
@@ -428,7 +446,8 @@ function injectScripts(jtffci, env_mission) {
428
446
  scriptTitle: 'Mission specific',
429
447
  scripts: ['200-mission.lua'],
430
448
  timing: 30,
431
- color: '0xff0000ff'
449
+ color: '0xff0000ff',
450
+ fromLibrary: false
432
451
  });
433
452
  }
434
453
  // traitement de la file d'attente des scripts (injection des triggers et des fichiers lua)
@@ -441,11 +460,12 @@ function injectScripts(jtffci, env_mission) {
441
460
  script.scriptTitle,
442
461
  mizObject,
443
462
  script.timing,
444
- script.color
463
+ script.color,
464
+ script.fromLibrary
445
465
  );
446
466
  missionObject['trig'] = tuple.tObject;
447
467
  missionObject['trigrules'] = tuple.trObject;
448
- mapResourceObject = tuple.mrObject;
468
+ mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
449
469
  mizObject = zipObject;
450
470
  }
451
471
  // injection des preset radio dans les avions humains
@@ -454,7 +474,7 @@ function injectScripts(jtffci, env_mission) {
454
474
  fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
455
475
  fs.cpSync('node_modules/@jtff/miztemplate-lib/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
456
476
  console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
457
- await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
477
+ mizObject = await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
458
478
  }
459
479
  // traitement de la file d'attente des settings (injection des triggers et des fichiers lua)
460
480
  if (settingsArray.length > 0) {
@@ -466,36 +486,35 @@ function injectScripts(jtffci, env_mission) {
466
486
  'Mission Settings',
467
487
  mizObject,
468
488
  15,
469
- '0xffff00ff'
489
+ '0xffff00ff',
490
+ false
470
491
  );
471
492
  missionObject['trig'] = tuple.tObject;
472
493
  missionObject['trigrules'] = tuple.trObject;
473
- mapResourceObject = tuple.mrObject;
494
+ mapResourceObject = _.merge(mapResourceObject,tuple.mrObject);
474
495
  mizObject = zipObject;
475
496
  }
476
- // creation du cichier miz dans l'espace de travail
477
- await fs.closeSync(fs.openSync(destinationMizFilePath, 'a'));
478
- // On fait une sauvegarde dans le folder de destination
479
- fs.writeFileSync(
480
- destinationMizFilePath,
481
- await mizObject.generateAsync({
482
- type: 'nodebuffer',
483
- streamFiles: true,
484
- compression: "DEFLATE",
485
- compressionOptions: {
486
- level: 9
487
- }
488
- })
489
- );
490
- // Sauvegarde de la mission avec scripts injectés
491
- await jtffci.mizlib.mizInjectMissionDataFile(
492
- destinationMizFilePath,
497
+ // réintégration du fichier mission dans l'archive
498
+ mizObject = await jtffci.mizlib.injectMissionObjectIntoZipObject(
499
+ mizObject,
493
500
  { mission: missionObject }
494
501
  );
495
- await jtffci.mizlib.mizInjectMapResourceFile(
496
- destinationMizFilePath,
502
+ mizObject = await jtffci.mizlib.injectMapResourceObjectIntoZipObject(
503
+ mizObject,
497
504
  { mapResource: mapResourceObject }
498
505
  );
506
+ // creation du fichier miz dans l'espace de travail
507
+ await fs.closeSync(fs.openSync(destinationMizFilePath, 'a'));
508
+ // On fait une sauvegarde dans le folder de destination
509
+ const inputZip = await mizObject.generateAsync({
510
+ type: 'nodebuffer',
511
+ streamFiles: true,
512
+ compression: "DEFLATE",
513
+ compressionOptions: {
514
+ level: 9
515
+ }
516
+ });
517
+ fs.writeFileSync(destinationMizFilePath, inputZip);
499
518
  // generation des outils CI JTFF
500
519
  await jtffci.deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, env_mission);
501
520
  console.log('...Done...');