@jtff/miztemplate-lib 3.0.4 → 3.0.6

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.
@@ -250,7 +250,10 @@ class MizTemplateCI{
250
250
  }
251
251
 
252
252
  async InjectCiScriptsIntoWorkspace(workspacePath) {
253
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci',workspacePath + '/.workspace/src/nodejs',{recursive: true});
253
+
254
+ this.mizlib.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci', workspacePath + '/.workspace/src/nodejs');
255
+
256
+ // fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci',workspacePath + '/.workspace/src/nodejs',{recursive: true});
254
257
  }
255
258
 
256
259
  async deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, mizFilePath) {
package/lib/mizlib.js CHANGED
@@ -7,6 +7,7 @@ const {promisify} = require("util");
7
7
  const fs = require("fs");
8
8
  const {getInstalledPathSync} = require("get-installed-path");
9
9
  const lstat = promisify(fs.lstat);
10
+ let _ = require('lodash');
10
11
 
11
12
  class Mizlib {
12
13
  constructor() {
@@ -41,7 +42,7 @@ class Mizlib {
41
42
  colorString
42
43
  );
43
44
  for (let luaScript of luaScriptsArray) {
44
- fs.cpSync(
45
+ fs.copyFileSync(
45
46
  [
46
47
  getInstalledPathSync('@jtff/miztemplate-lib',{local: true}),
47
48
  '/lua/',
@@ -55,8 +56,7 @@ class Mizlib {
55
56
  folderPath,
56
57
  "/",
57
58
  path.basename(luaScript)
58
- ].join(""),
59
- {force: true}
59
+ ].join("")
60
60
  );
61
61
  }
62
62
  return tuple;
@@ -120,16 +120,14 @@ class Mizlib {
120
120
  .filter(filename => path.extname(filename).toLowerCase()==='.lua');
121
121
  for (let file of srcFiles) {
122
122
  console.log('updating src/' + file + ' from the miztemplate-lib');
123
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/src/' + file,
124
- '.workspace/src/' + file,
125
- {force: true}
123
+ fs.copyFileSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/src/' + file,
124
+ '.workspace/src/' + file
126
125
  );
127
126
  }
128
127
  for (let file of libFiles) {
129
128
  console.log('updating lib/' + file + ' from the miztemplate-lib');
130
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/lib/' + file,
131
- '.workspace/lib/' + file,
132
- {force: true}
129
+ fs.copyFileSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/lib/' + file,
130
+ '.workspace/lib/' + file
133
131
  );
134
132
  }
135
133
  this.injectLuaFilesFromFolderIntoZipObject(zipObject, '.workspace/src', mizSettingSubFolder);
@@ -329,6 +327,22 @@ class Mizlib {
329
327
  }
330
328
  }
331
329
 
330
+ copyRecursiveSync(src, dest) {
331
+ let exists = fs.existsSync(src);
332
+ let stats = exists && fs.statSync(src);
333
+ let isDirectory = exists && stats.isDirectory();
334
+ if (isDirectory) {
335
+ fs.mkdirSync(dest);
336
+ fs.readdirSync(src).forEach(function(childItemName) {
337
+ copyRecursiveSync(path.join(src, childItemName),
338
+ path.join(dest, childItemName));
339
+ });
340
+ } else {
341
+ fs.copyFileSync(src, dest);
342
+ }
343
+ };
344
+
345
+
332
346
  async updateWorkspaceWithSingleSoundFolder(workspacePath, folderString) {
333
347
  if (
334
348
  fs.existsSync(
@@ -358,11 +372,16 @@ class Mizlib {
358
372
  "/.workspace/resources/sounds/",
359
373
  folderString
360
374
  ].join(""), {recursive: true});
361
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
375
+ this.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
362
376
  workspacePath,
363
377
  "/.workspace/resources/sounds/",
364
378
  folderString
365
- ].join(""), {recursive: true});
379
+ ].join(""));
380
+ // fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
381
+ // workspacePath,
382
+ // "/.workspace/resources/sounds/",
383
+ // folderString
384
+ // ].join(""), {recursive: true});
366
385
  }
367
386
  }
368
387
 
@@ -451,7 +470,7 @@ class Mizlib {
451
470
  if (_.isEmpty(data)) {
452
471
  return `\n${indentation}{\n${indentation}}`;
453
472
  }
454
- return `\n${indentation}{\n${map(
473
+ return `\n${indentation}{\n${_.map(
455
474
  data,
456
475
  (value, key) =>
457
476
  `${indentation} [${!_.isNaN(key)?key:this.js2Lua(key)}] = ${this.js2Lua(value, depth + 1)}${_.isObject(value)?`, -- end of [${!_.isNaN(key)?key:this.js2Lua(key)}]`:","}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jtff/miztemplate-lib",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "JTFF mission template library",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -473,7 +473,8 @@ function injectScripts(jtffci, env_mission) {
473
473
  if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_radio_presets)) {
474
474
  // injection des preset radio
475
475
  fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
476
- fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
476
+ jtffci.mizlib.copyRecursiveSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre);
477
+ // fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
477
478
  console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
478
479
  await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
479
480
  }