@jtff/miztemplate-lib 3.0.0-rc24 → 3.0.0-rc26
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/jtff-lib-ci.js +2 -1
- package/lib/mizlib.js +10 -8
- package/package.json +2 -1
- package/scripts/inject-scripts.js +2 -1
- package/scripts/template-update.js +50 -32
package/lib/jtff-lib-ci.js
CHANGED
|
@@ -5,6 +5,7 @@ const path = require("path");
|
|
|
5
5
|
const { google } = require("googleapis");
|
|
6
6
|
const ftpClient = require('ftp');
|
|
7
7
|
const Mizlib = require("./mizlib");
|
|
8
|
+
const { getInstalledPathSync } = require('get-installed-path')
|
|
8
9
|
|
|
9
10
|
class MizTemplateCI{
|
|
10
11
|
constructor(config) {
|
|
@@ -249,7 +250,7 @@ class MizTemplateCI{
|
|
|
249
250
|
}
|
|
250
251
|
|
|
251
252
|
async InjectCiScriptsIntoWorkspace(workspacePath) {
|
|
252
|
-
fs.cpSync('
|
|
253
|
+
fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/ci',workspacePath + '/.workspace/src/nodejs',{recursive: true});
|
|
253
254
|
}
|
|
254
255
|
|
|
255
256
|
async deployCIScriptsFromZipObjectIntoWorkspace(workspacePath, mizObject, mizFilePath) {
|
package/lib/mizlib.js
CHANGED
|
@@ -5,6 +5,7 @@ const path = require("path");
|
|
|
5
5
|
const {format, parse} = require("lua-json");
|
|
6
6
|
const {promisify} = require("util");
|
|
7
7
|
const fs = require("fs");
|
|
8
|
+
const {getInstalledPathSync} = require("get-installed-path");
|
|
8
9
|
const lstat = promisify(fs.lstat);
|
|
9
10
|
|
|
10
11
|
class Mizlib {
|
|
@@ -42,7 +43,8 @@ class Mizlib {
|
|
|
42
43
|
for (let luaScript of luaScriptsArray) {
|
|
43
44
|
fs.cpSync(
|
|
44
45
|
[
|
|
45
|
-
'
|
|
46
|
+
getInstalledPathSync('@jtff/miztemplate-lib',{local: true}),
|
|
47
|
+
'/lua/',
|
|
46
48
|
folderPath,
|
|
47
49
|
'/',
|
|
48
50
|
luaScript
|
|
@@ -112,20 +114,20 @@ class Mizlib {
|
|
|
112
114
|
const zipObject = await this.getZipObjectFromMizPath(mizPath);
|
|
113
115
|
const missionObject = await this.getMissionObjectFromZipObject(zipObject);
|
|
114
116
|
const strTheatreSettings = missionObject.theatre;
|
|
115
|
-
const srcFiles = fs.readdirSync(
|
|
117
|
+
const srcFiles = fs.readdirSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + "/lua/src",{recursive: true})
|
|
116
118
|
.filter(filename => path.extname(filename).toLowerCase()==='.lua' && !(filename.startsWith('200-')));
|
|
117
|
-
const libFiles = fs.readdirSync(
|
|
119
|
+
const libFiles = fs.readdirSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + "/lua/lib",{recursive: true})
|
|
118
120
|
.filter(filename => path.extname(filename).toLowerCase()==='.lua');
|
|
119
121
|
for (let file of srcFiles) {
|
|
120
122
|
console.log('updating src/' + file + ' from the miztemplate-lib');
|
|
121
|
-
fs.cpSync('
|
|
123
|
+
fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/src/' + file,
|
|
122
124
|
'.workspace/src/' + file,
|
|
123
125
|
{force: true}
|
|
124
126
|
);
|
|
125
127
|
}
|
|
126
128
|
for (let file of libFiles) {
|
|
127
129
|
console.log('updating lib/' + file + ' from the miztemplate-lib');
|
|
128
|
-
fs.cpSync('
|
|
130
|
+
fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/lua/lib/' + file,
|
|
129
131
|
'.workspace/lib/' + file,
|
|
130
132
|
{force: true}
|
|
131
133
|
);
|
|
@@ -349,14 +351,14 @@ class Mizlib {
|
|
|
349
351
|
].join(""), {recursive: true});
|
|
350
352
|
}
|
|
351
353
|
if (
|
|
352
|
-
fs.existsSync('
|
|
353
|
-
fs.lstatSync('
|
|
354
|
+
fs.existsSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString) &&
|
|
355
|
+
fs.lstatSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString).isDirectory()) {
|
|
354
356
|
fs.mkdirSync([
|
|
355
357
|
workspacePath,
|
|
356
358
|
"/.workspace/resources/sounds/",
|
|
357
359
|
folderString
|
|
358
360
|
].join(""), {recursive: true});
|
|
359
|
-
fs.cpSync('
|
|
361
|
+
fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/sounds/' + folderString,[
|
|
360
362
|
workspacePath,
|
|
361
363
|
"/.workspace/resources/sounds/",
|
|
362
364
|
folderString
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jtff/miztemplate-lib",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc26",
|
|
4
4
|
"description": "JTFF mission template library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"homepage": "https://github.com/JTFF-mission-scripts/miztemplate-lib#readme",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"ftp": "^0.3.10",
|
|
35
|
+
"get-installed-path": "^4.0.8",
|
|
35
36
|
"googleapis": "^92.0.0",
|
|
36
37
|
"jszip": "^3.10.1",
|
|
37
38
|
"lodash": "^4.17.21",
|
|
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const prompt = require('prompt');
|
|
4
4
|
let _ = require('lodash');
|
|
5
|
+
const {getInstalledPathSync} = require("get-installed-path");
|
|
5
6
|
|
|
6
7
|
function injectScripts(jtffci, env_mission) {
|
|
7
8
|
const workspacePath = [
|
|
@@ -472,7 +473,7 @@ function injectScripts(jtffci, env_mission) {
|
|
|
472
473
|
if ((/^y\b|o\b|yes\b|oui\b/i).test(prompt_result.inject_radio_presets)) {
|
|
473
474
|
// injection des preset radio
|
|
474
475
|
fs.mkdirSync(workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true});
|
|
475
|
-
fs.cpSync('
|
|
476
|
+
fs.cpSync(getInstalledPathSync('@jtff/miztemplate-lib',{local: true}) + '/resources/radios/' + missionObject.theatre,workspacePath + '/resources/radios/' + missionObject.theatre,{recursive: true})
|
|
476
477
|
console.log(destinationMizFilePath + ": injecting radio presets declared in resources/radios/" + missionObject.theatre);
|
|
477
478
|
await jtffci.mizlib.injectRadioPresetsFromFolderIntoZipObject(mizObject, workspacePath + '/resources/radios/' + missionObject.theatre);
|
|
478
479
|
}
|
|
@@ -3,43 +3,61 @@ const fs = require("fs");
|
|
|
3
3
|
function templateUpdate(jtffci) {
|
|
4
4
|
fs.mkdirSync(jtffci.config.general.missionFolder, { recursive: true });
|
|
5
5
|
jtffci.config.missionTemplates.map(async missionTemplate => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
if (missionTemplate.filename) {
|
|
7
|
+
await jtffci.mizlib.buildMizFileFromMizTemplate(
|
|
8
|
+
missionTemplate.filename,
|
|
9
|
+
[ missionTemplate.filename,
|
|
10
|
+
"-new.miz"
|
|
11
|
+
].join(""),
|
|
12
|
+
(jtffci.config.missionTemplates.length > 1) ? missionTemplate.theatre : '');
|
|
13
|
+
if (fs.existsSync(missionTemplate.filename)) {
|
|
14
|
+
fs.unlinkSync(missionTemplate.filename);
|
|
15
|
+
}
|
|
16
|
+
fs.renameSync(
|
|
17
|
+
[ missionTemplate.filename,
|
|
18
|
+
"-new.miz"
|
|
19
|
+
].join(""),
|
|
20
|
+
missionTemplate.filename);
|
|
21
|
+
} else {
|
|
22
|
+
await this.mizlib.buildMizFileFromMizTemplate(
|
|
23
|
+
[ missionTemplate.prefix,
|
|
24
|
+
'_',
|
|
25
|
+
missionTemplate.theatre,
|
|
26
|
+
".miz"
|
|
27
|
+
].join(""),
|
|
28
|
+
[ missionTemplate.prefix,
|
|
29
|
+
'_',
|
|
30
|
+
missionTemplate.theatre,
|
|
31
|
+
"-new.miz"
|
|
32
|
+
].join(""),
|
|
33
|
+
missionTemplate.theatre);
|
|
34
|
+
if (fs.existsSync([
|
|
24
35
|
missionTemplate.prefix,
|
|
25
36
|
'_',
|
|
26
37
|
missionTemplate.theatre,
|
|
27
38
|
".miz"
|
|
28
|
-
].join(""))
|
|
39
|
+
].join(""))) {
|
|
40
|
+
fs.unlinkSync([
|
|
41
|
+
missionTemplate.prefix,
|
|
42
|
+
'_',
|
|
43
|
+
missionTemplate.theatre,
|
|
44
|
+
".miz"
|
|
45
|
+
].join(""));
|
|
46
|
+
}
|
|
47
|
+
fs.renameSync([
|
|
48
|
+
missionTemplate.prefix,
|
|
49
|
+
'_',
|
|
50
|
+
missionTemplate.theatre,
|
|
51
|
+
"-new.miz"
|
|
52
|
+
].join(""),
|
|
53
|
+
[
|
|
54
|
+
missionTemplate.prefix,
|
|
55
|
+
'_',
|
|
56
|
+
missionTemplate.theatre,
|
|
57
|
+
".miz"
|
|
58
|
+
].join("")
|
|
59
|
+
);
|
|
29
60
|
}
|
|
30
|
-
fs.renameSync([
|
|
31
|
-
missionTemplate.prefix,
|
|
32
|
-
'_',
|
|
33
|
-
missionTemplate.theatre,
|
|
34
|
-
"-new.miz"
|
|
35
|
-
].join(""),
|
|
36
|
-
[
|
|
37
|
-
missionTemplate.prefix,
|
|
38
|
-
'_',
|
|
39
|
-
missionTemplate.theatre,
|
|
40
|
-
".miz"
|
|
41
|
-
].join("")
|
|
42
|
-
);
|
|
43
61
|
});
|
|
44
62
|
}
|
|
45
63
|
|