@jtff/miztemplate-lib 3.0.0-rc22 → 3.0.0-rc24

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 CHANGED
@@ -108,7 +108,7 @@ class Mizlib {
108
108
  return MizFile.loadAsync(mizData);
109
109
  }
110
110
 
111
- async buildMizFileFromMizTemplate(mizPath, copyPath, singleMission= true) {
111
+ async buildMizFileFromMizTemplate(mizPath, copyPath, mizSettingSubFolder= '') {
112
112
  const zipObject = await this.getZipObjectFromMizPath(mizPath);
113
113
  const missionObject = await this.getMissionObjectFromZipObject(zipObject);
114
114
  const strTheatreSettings = missionObject.theatre;
@@ -130,11 +130,11 @@ class Mizlib {
130
130
  {force: true}
131
131
  );
132
132
  }
133
- this.injectLuaFilesFromFolderIntoZipObject(zipObject, '.workspace/src');
134
- this.injectLuaFilesFromFolderIntoZipObject(zipObject, '.workspace/lib');
135
- this.injectLuaFilesFromFolderIntoZipObject(zipObject, 'src');
133
+ this.injectLuaFilesFromFolderIntoZipObject(zipObject, '.workspace/src', mizSettingSubFolder);
134
+ this.injectLuaFilesFromFolderIntoZipObject(zipObject, '.workspace/lib', mizSettingSubFolder);
135
+ this.injectLuaFilesFromFolderIntoZipObject(zipObject, ['src',mizSettingSubFolder.length > 0 ? '/' + mizSettingSubFolder : ''].join(''), mizSettingSubFolder);
136
136
  await this.injectRadioPresetsFromFolderIntoZipObject(zipObject, 'resources/radios/' + strTheatreSettings);
137
- this.injectSettingsLuaFilesFromFolderIntoZipObject(zipObject, singleMission ? '' : strTheatreSettings);
137
+ this.injectSettingsLuaFilesFromFolderIntoZipObject(zipObject, mizSettingSubFolder.length > 0 ? mizSettingSubFolder : '');
138
138
  await this.injectSoundFoldersIntoZipObject(zipObject);
139
139
  const inputZip = await zipObject.generateAsync({
140
140
  type: 'nodebuffer',
@@ -236,9 +236,9 @@ class Mizlib {
236
236
  return zipStream.file("l10n/DEFAULT/mapResource").async("string");
237
237
  }
238
238
 
239
- injectLuaFilesFromFolderIntoZipObject(zip, folderPath) {
239
+ injectLuaFilesFromFolderIntoZipObject(zip, folderPath, mizSettingSubFolder) {
240
240
  for (let file of fs.readdirSync(folderPath).filter(file => file.endsWith(".lua"))) {
241
- console.log('injecting up2date ' + folderPath + '/' + file + ' file in archive');
241
+ console.log('injecting up2date ' + folderPath + '/' + file + ' file in ' + mizSettingSubFolder + ' archive');
242
242
  this.injectFileIntoZipObject(zip, folderPath + "/" + file);
243
243
  };
244
244
  }
@@ -308,19 +308,16 @@ class Mizlib {
308
308
  this.injectMissionObjectIntoZipObject(zip, {mission: mission_object});
309
309
  }
310
310
 
311
- injectSettingsLuaFilesFromFolderIntoZipObject(zip, strTheatre) {
312
- for (let file of fs.readdirSync(['settings',strTheatre.length > 0 ? '/' + strTheatre : ''].join('')).filter(file => path.extname(file).toLowerCase()==='.lua')) {
313
- console.log(['updating settings',strTheatre.length > 0 ? '/' + strTheatre : '','/',file,' file in miz file'].join(''));
314
- this.injectFileIntoZipObject(zip, ['settings',strTheatre.length > 0 ? '/' + strTheatre : '','/',file].join(''));
311
+ injectSettingsLuaFilesFromFolderIntoZipObject(zip, settingsSubFolder) {
312
+ for (let file of fs.readdirSync(['settings',settingsSubFolder.length > 0 ? '/' + settingsSubFolder : ''].join('')).filter(file => path.extname(file).toLowerCase()==='.lua')) {
313
+ console.log(['updating settings',settingsSubFolder.length > 0 ? '/' + settingsSubFolder : '','/',file,' file in miz file'].join(''));
314
+ this.injectFileIntoZipObject(zip, ['settings',settingsSubFolder.length > 0 ? '/' + settingsSubFolder : '','/',file].join(''));
315
315
  }
316
316
  }
317
317
 
318
318
  async injectSoundFoldersIntoZipObject(zip) {
319
319
  if (fs.existsSync('resources/sounds') && fs.lstatSync('resources/sounds').isDirectory()) {
320
- const folderArray = fs.readdirSync('resources/sounds');
321
- for (const folder of folderArray) {
322
- await this.injectSingleSoundFolderIntoZipObject(zip, '.', folder, false);
323
- }
320
+ await this.injectSingleSoundFolderIntoZipObject(zip, '.', 'resources/sounds', false);
324
321
  }
325
322
  if (fs.existsSync('.workspace/resources/sounds') && fs.lstatSync('.workspace/resources/sounds').isDirectory()) {
326
323
  const folderArray = fs.readdirSync('.workspace/resources/sounds');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtff/miztemplate-lib",
3
- "version": "3.0.0-rc22",
3
+ "version": "3.0.0-rc24",
4
4
  "description": "JTFF mission template library",
5
5
  "main": "index.js",
6
6
  "files": [
package/scripts/build.js CHANGED
@@ -7,7 +7,7 @@ function build(jtffci) {
7
7
  await jtffci.mizlib.buildMizFileFromMizTemplate(
8
8
  missionTemplate.filename,
9
9
  jtffci.getDestinationMizFilePathFromConfigMissionTemplate(missionTemplate),
10
- (jtffci.config.missionTemplates.length > 1) ? false : true);
10
+ (jtffci.config.missionTemplates.length > 1) ? missionTemplate.theatre : '');
11
11
  } else {
12
12
  await jtffci.mizlib.buildMizFileFromMizTemplate([
13
13
  [missionTemplate.prefix,
@@ -15,7 +15,7 @@ function build(jtffci) {
15
15
  ".miz"
16
16
  ].join(""),
17
17
  jtffci.getDestinationMizFilePathFromConfigMissionTemplate(missionTemplate),
18
- false);
18
+ missionTemplate.theatre);
19
19
  }
20
20
  let publicationConfig = {
21
21
  theatre: missionTemplate.theatre,