dcs-git-utils 1.0.13 → 1.0.15
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/README.md +3 -1
- package/dist/main.js +22 -6
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
- package/src/main.ts +22 -6
package/README.md
CHANGED
|
@@ -24,4 +24,6 @@ Select the .miz you want to work on and use git to version control the mission!
|
|
|
24
24
|
|
|
25
25
|
### Cmd args for debugging purposes
|
|
26
26
|
|
|
27
|
-
a single arg of a .miz filepath can be given to override file selection
|
|
27
|
+
- a single arg of a .miz filepath can be given to override file selection
|
|
28
|
+
- --nowatch/-n to run once without starting watchers
|
|
29
|
+
- --force/-f=miz|out to force either miz or out as source
|
package/dist/main.js
CHANGED
|
@@ -12,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
14
|
};
|
|
15
|
+
var _a;
|
|
15
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
17
|
const node_process_1 = __importDefault(require("node:process"));
|
|
17
18
|
const node_fs_1 = require("node:fs");
|
|
@@ -24,6 +25,7 @@ const modified_date_1 = require("./files/modified-date");
|
|
|
24
25
|
const [_0, _1, file, ...args] = node_process_1.default.argv;
|
|
25
26
|
const shouldBackup = args.some(arg => arg === "--backup" || arg === "-b");
|
|
26
27
|
const noWatch = args.some(arg => arg === "--nowatch" || "-n");
|
|
28
|
+
const force = (_a = args.find(arg => arg.startsWith("--force") || arg.startsWith("-f"))) === null || _a === void 0 ? void 0 : _a.split("=")[1];
|
|
27
29
|
const backupMiz = (filepath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
30
|
if (!(filepath === null || filepath === void 0 ? void 0 : filepath.indexOf(".miz"))) {
|
|
29
31
|
throw new Error('no miz file ext');
|
|
@@ -41,25 +43,39 @@ const isOutDirLatest = (outDir, miz) => __awaiter(void 0, void 0, void 0, functi
|
|
|
41
43
|
console.log(`outDir latest: ${latestOutDir}, miz modified at: ${mizModified}`);
|
|
42
44
|
return latestOutDir > mizModified;
|
|
43
45
|
});
|
|
44
|
-
const initialize = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const initialize = (force) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
47
|
const { missionPath, outDir, } = yield (0, config_1.initializeConfig)({ file });
|
|
46
48
|
if (shouldBackup) {
|
|
47
49
|
backupMiz(missionPath);
|
|
48
50
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const outDirIsLatest = yield isOutDirLatest(outDir, missionPath);
|
|
52
|
+
if (force === "out") {
|
|
53
|
+
console.log('forcing out as source');
|
|
51
54
|
yield (0, compression_1.handleArchive)(outDir, missionPath);
|
|
52
55
|
}
|
|
53
|
-
else {
|
|
54
|
-
console.log("
|
|
56
|
+
else if (force === "miz") {
|
|
57
|
+
console.log("forcing .miz as source");
|
|
55
58
|
const files = yield (0, compression_1.unpackMiz)(missionPath, outDir);
|
|
56
59
|
const filePaths = files.filter(f => f.type === "file").map(f => node_path_1.default.join(outDir, f.path));
|
|
57
60
|
yield (0, sorting_1.sortFiles)(filePaths);
|
|
58
61
|
}
|
|
62
|
+
else if (outDirIsLatest) {
|
|
63
|
+
console.log('out is latest. out as source');
|
|
64
|
+
yield (0, compression_1.handleArchive)(outDir, missionPath);
|
|
65
|
+
}
|
|
66
|
+
else if (!outDirIsLatest) {
|
|
67
|
+
console.log("miz is latest. .miz as source");
|
|
68
|
+
const files = yield (0, compression_1.unpackMiz)(missionPath, outDir);
|
|
69
|
+
const filePaths = files.filter(f => f.type === "file").map(f => node_path_1.default.join(outDir, f.path));
|
|
70
|
+
yield (0, sorting_1.sortFiles)(filePaths);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
throw new Error('Shouldnt be possible, either a source is forced or a source is selected by modified date');
|
|
74
|
+
}
|
|
59
75
|
return { mizPath: missionPath, outDir };
|
|
60
76
|
});
|
|
61
77
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
const { mizPath, outDir } = yield initialize();
|
|
78
|
+
const { mizPath, outDir } = yield initialize(force);
|
|
63
79
|
if (!noWatch) {
|
|
64
80
|
(0, watchers_1.startWatchers)(mizPath, outDir);
|
|
65
81
|
}
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,gEAAmC;AACnC,qCAA+D;AAC/D,0DAA4B;AAC5B,yCAA2C;AAC3C,+CAAyD;AACzD,uCAAsC;AACtC,qCAA4C;AAC5C,yDAAgE;AAEhE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,sBAAO,CAAC,IAAI,CAAC;AAE7C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC;AAC1E,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC;AAC9D,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAEjG,MAAM,SAAS,GAAG,CAAO,QAAgB,EAAE,EAAE;IAEzC,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uB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CAAC;SACI,CAAC;QACF,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAC;IAChH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AAC5C,CAAC,CAAA,CAAA;AAED,CAAC,GAAS,EAAE;IAER,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC;IAEpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,IAAA,wBAAa,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;AACL,CAAC,CAAA,CAAC,EAAE,CAAA"}
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -13,6 +13,7 @@ const [_0, _1, file, ...args] = process.argv;
|
|
|
13
13
|
|
|
14
14
|
const shouldBackup = args.some(arg => arg === "--backup" || arg === "-b");
|
|
15
15
|
const noWatch = args.some(arg => arg === "--nowatch" || "-n");
|
|
16
|
+
const force = args.find(arg => arg.startsWith("--force") || arg.startsWith("-f"))?.split("=")[1];
|
|
16
17
|
|
|
17
18
|
const backupMiz = async (filepath: string) => {
|
|
18
19
|
|
|
@@ -21,6 +22,7 @@ const backupMiz = async (filepath: string) => {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const fileWithoutExt = filepath.replace(path.extname(filepath), "");
|
|
25
|
+
|
|
24
26
|
await fs.copyFile(filepath, `${fileWithoutExt}_backup_${new Date().toISOString().replace(/:/g, '-')}.miz`);
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -37,7 +39,7 @@ const isOutDirLatest = async (outDir: string, miz: string) => {
|
|
|
37
39
|
return latestOutDir > mizModified;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
const initialize = async () => {
|
|
42
|
+
const initialize = async (force?: string) => {
|
|
41
43
|
|
|
42
44
|
const { missionPath, outDir, } = await initializeConfig({ file });
|
|
43
45
|
|
|
@@ -45,22 +47,36 @@ const initialize = async () => {
|
|
|
45
47
|
backupMiz(missionPath);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const outDirIsLatest = await isOutDirLatest(outDir, missionPath)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if (force === "out") {
|
|
54
|
+
console.log('forcing out as source');
|
|
55
|
+
await handleArchive(outDir, missionPath);
|
|
56
|
+
} else if (force === "miz") {
|
|
57
|
+
console.log("forcing .miz as source");
|
|
58
|
+
const files = await unpackMiz(missionPath, outDir);
|
|
59
|
+
const filePaths = files.filter(f => f.type === "file").map(f => path.join(outDir, f.path));
|
|
60
|
+
await sortFiles(filePaths);
|
|
61
|
+
} else if (outDirIsLatest) {
|
|
62
|
+
console.log('out is latest. out as source');
|
|
50
63
|
await handleArchive(outDir, missionPath);
|
|
51
|
-
} else {
|
|
52
|
-
console.log("
|
|
64
|
+
} else if (!outDirIsLatest) {
|
|
65
|
+
console.log("miz is latest. .miz as source");
|
|
53
66
|
const files = await unpackMiz(missionPath, outDir);
|
|
54
67
|
const filePaths = files.filter(f => f.type === "file").map(f => path.join(outDir, f.path));
|
|
55
68
|
await sortFiles(filePaths);
|
|
56
69
|
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error('Shouldnt be possible, either a source is forced or a source is selected by modified date');
|
|
72
|
+
}
|
|
57
73
|
|
|
58
74
|
return { mizPath: missionPath, outDir };
|
|
59
75
|
}
|
|
60
76
|
|
|
61
77
|
(async () => {
|
|
62
78
|
|
|
63
|
-
const { mizPath, outDir } = await initialize();
|
|
79
|
+
const { mizPath, outDir } = await initialize(force);
|
|
64
80
|
|
|
65
81
|
if (!noWatch) {
|
|
66
82
|
startWatchers(mizPath, outDir);
|