dcs-git-utils 1.0.0 → 1.0.9
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/.github/workflows/pr.yml +33 -33
- package/.github/workflows/release.yml +71 -64
- package/.vscode/launch.json +22 -22
- package/LICENSE +21 -21
- package/README.md +24 -15
- package/dist/compression.js +119 -109
- package/dist/compression.js.map +1 -1
- package/dist/config.js +149 -139
- package/dist/config.js.map +1 -1
- package/dist/fengari-wrapper.js +88 -78
- package/dist/fengari-wrapper.js.map +1 -1
- package/dist/files/file-picker.js +75 -76
- package/dist/files/file-picker.js.map +1 -1
- package/dist/files/miz-selector.js +23 -23
- package/dist/files/miz-selector.js.map +1 -1
- package/dist/lua +72 -72
- package/dist/main.js +51 -48
- package/dist/main.js.map +1 -1
- package/dist/sorting.js +153 -143
- package/dist/sorting.js.map +1 -1
- package/dist/watchers.js +92 -82
- package/dist/watchers.js.map +1 -1
- package/lua/sorter_lib.lua +72 -72
- package/package.json +61 -62
- package/src/compression.ts +87 -87
- package/src/config.ts +119 -119
- package/src/fengari-wrapper.ts +67 -67
- package/src/files/file-picker.ts +63 -63
- package/src/files/miz-selector.ts +9 -9
- package/src/main.ts +53 -49
- package/src/sorting.ts +127 -127
- package/src/watchers.ts +57 -57
- package/tests/sorting.spec.ts +25 -25
- package/tsconfig.json +100 -100
- package/vitest.config.ts +9 -9
package/.github/workflows/pr.yml
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
name: Pull Request Checks
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
branches: [ "main" ] # Or "master", depending on your default branch
|
|
6
|
-
# This triggers on new PRs, commits to existing PRs, and re-opened PRs
|
|
7
|
-
|
|
8
|
-
permissions:
|
|
9
|
-
contents: read
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
test:
|
|
13
|
-
name: Run CI Tests
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
|
|
16
|
-
steps:
|
|
17
|
-
# 1. Checkout the repository code
|
|
18
|
-
- name: Checkout Code
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
|
|
21
|
-
# 2. Setup Node.js environment
|
|
22
|
-
- name: Setup Node.js
|
|
23
|
-
uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: '18' # Matches your pkg target
|
|
26
|
-
cache: 'npm' # Caches node_modules for faster runs
|
|
27
|
-
|
|
28
|
-
# 3. Install dependencies strictly from package-lock.json
|
|
29
|
-
- name: Install Dependencies
|
|
30
|
-
run: npm ci
|
|
31
|
-
|
|
32
|
-
# 4. Run the specific test command
|
|
33
|
-
- name: Run Tests
|
|
1
|
+
name: Pull Request Checks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ "main" ] # Or "master", depending on your default branch
|
|
6
|
+
# This triggers on new PRs, commits to existing PRs, and re-opened PRs
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
name: Run CI Tests
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
# 1. Checkout the repository code
|
|
18
|
+
- name: Checkout Code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
# 2. Setup Node.js environment
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '18' # Matches your pkg target
|
|
26
|
+
cache: 'npm' # Caches node_modules for faster runs
|
|
27
|
+
|
|
28
|
+
# 3. Install dependencies strictly from package-lock.json
|
|
29
|
+
- name: Install Dependencies
|
|
30
|
+
run: npm ci
|
|
31
|
+
|
|
32
|
+
# 4. Run the specific test command
|
|
33
|
+
- name: Run Tests
|
|
34
34
|
run: npm run test:ci
|
|
@@ -1,65 +1,72 @@
|
|
|
1
|
-
name: Build and Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- 'v*' # Triggers only on version tags like v1.0.0, v2.1.5
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
jobs:
|
|
12
|
-
build-and-release:
|
|
13
|
-
runs-on: ubuntu-latest
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
# 1. Checkout the code
|
|
17
|
-
- name: Checkout code
|
|
18
|
-
uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
- name:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
name: Build and Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*' # Triggers only on version tags like v1.0.0, v2.1.5
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-and-release:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
# 1. Checkout the code
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# 2. Setup Node.js
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v6
|
|
24
|
+
with:
|
|
25
|
+
node-version: '18'
|
|
26
|
+
|
|
27
|
+
- name: Update npm
|
|
28
|
+
run: sudo npm install -g npm@latest
|
|
29
|
+
|
|
30
|
+
# 3. Install Dependencies
|
|
31
|
+
- name: Install Dependencies
|
|
32
|
+
run: npm ci
|
|
33
|
+
|
|
34
|
+
- name: Set Package Version from Git Tag
|
|
35
|
+
# The github.ref is the full tag path (refs/tags/v1.0.1).
|
|
36
|
+
# We use a shell command to trim "refs/tags/v" to get "1.0.1".
|
|
37
|
+
run: |
|
|
38
|
+
VERSION="${{ github.ref_name }}"
|
|
39
|
+
# The 'npm version' command updates package.json and package-lock.json
|
|
40
|
+
npm version "$VERSION" --no-git-tag-version --allow-same-version
|
|
41
|
+
|
|
42
|
+
- name: Verify Updated Version
|
|
43
|
+
run: cat package.json | grep version
|
|
44
|
+
|
|
45
|
+
# 4. Build (TypeScript -> JS + Copy Lua Assets)
|
|
46
|
+
- name: Build Project
|
|
47
|
+
run: npm run build
|
|
48
|
+
|
|
49
|
+
- run: npm config set //registry.npmjs.org/:_authToken "${{ secrets.NPM_TOKEN }}"
|
|
50
|
+
|
|
51
|
+
- run: npm publish
|
|
52
|
+
|
|
53
|
+
# 5. Package (Generate Binaries)
|
|
54
|
+
# This runs 'pkg .' and creates the 3 executables (win, linux, macos)
|
|
55
|
+
- name: Create Executables
|
|
56
|
+
run: npm run package
|
|
57
|
+
|
|
58
|
+
# 6. Create GitHub Release
|
|
59
|
+
- name: Create Release
|
|
60
|
+
id: create_release
|
|
61
|
+
uses: softprops/action-gh-release@v1
|
|
62
|
+
with:
|
|
63
|
+
tag_name: ${{ github.ref_name }}
|
|
64
|
+
name: Release ${{ github.ref_name }}
|
|
65
|
+
draft: false
|
|
66
|
+
prerelease: false
|
|
67
|
+
generate_release_notes: true
|
|
68
|
+
files: |
|
|
69
|
+
bin/dcs-git-utils-win.exe
|
|
70
|
+
bin/dcs-git-utils-linux
|
|
71
|
+
env:
|
|
65
72
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/.vscode/launch.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"name": "DEbug",
|
|
9
|
-
"type": "node",
|
|
10
|
-
"request": "launch",
|
|
11
|
-
"preLaunchTask": "npm: prestart",
|
|
12
|
-
"autoAttachChildProcesses": true,
|
|
13
|
-
"skipFiles": [
|
|
14
|
-
"<node_internals>/**",
|
|
15
|
-
"**/node_modules/**"
|
|
16
|
-
],
|
|
17
|
-
"program": "${workspaceRoot}/dist/main.js",
|
|
18
|
-
"cwd": "${workspaceRoot}",
|
|
19
|
-
"smartStep": true,
|
|
20
|
-
"console": "integratedTerminal"
|
|
21
|
-
}
|
|
22
|
-
]
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "DEbug",
|
|
9
|
+
"type": "node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"preLaunchTask": "npm: prestart",
|
|
12
|
+
"autoAttachChildProcesses": true,
|
|
13
|
+
"skipFiles": [
|
|
14
|
+
"<node_internals>/**",
|
|
15
|
+
"**/node_modules/**"
|
|
16
|
+
],
|
|
17
|
+
"program": "${workspaceRoot}/dist/main.js",
|
|
18
|
+
"cwd": "${workspaceRoot}",
|
|
19
|
+
"smartStep": true,
|
|
20
|
+
"console": "integratedTerminal"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
23
|
}
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Martin Backudd
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Martin Backudd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
# DCS git tool
|
|
2
|
-
|
|
3
|
-
DCS shuffles the keys in the configs when saving, to be able to version control, we need to sort the keys of config objects.
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
# DCS git tool
|
|
2
|
+
|
|
3
|
+
DCS shuffles the keys in the configs when saving, to be able to version control, we need to sort the keys of config objects.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
Select the .miz you want to work on and use git to version control the mission!
|
|
7
|
+
|
|
8
|
+
## Alternatives to running it
|
|
9
|
+
|
|
10
|
+
- ```npx dcs-git-utils```
|
|
11
|
+
- download the exe's from releases
|
|
12
|
+
- clone the repo
|
|
13
|
+
|
|
14
|
+
## Flow
|
|
15
|
+
|
|
16
|
+
- If .miz is selected, extracts content into ./out and sorts all configs.
|
|
17
|
+
- If ./out exists, creates a .miz
|
|
18
|
+
|
|
19
|
+
- (When saving in editor) After writing the .miz completes, it unpacks the archive and sorts the content, THEN re-archives into the .miz again to keep everything consistent for version control.
|
|
20
|
+
- When editing anything in ./out, archive (.miz) is created from ./out.
|
|
21
|
+
|
|
22
|
+
### Cmd args for debugging purposes
|
|
23
|
+
|
|
24
|
+
a single arg of a .miz filepath can be given to override file selection
|
package/dist/compression.js
CHANGED
|
@@ -1,110 +1,120 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
) {
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.unpackMiz = exports.handleArchive = void 0;
|
|
49
|
+
exports.checkStable = checkStable;
|
|
50
|
+
const node_fs_1 = __importStar(require("node:fs"));
|
|
51
|
+
const archiver_1 = __importDefault(require("archiver"));
|
|
52
|
+
const decompress_1 = __importDefault(require("decompress"));
|
|
53
|
+
function checkStable(filePath_1) {
|
|
54
|
+
return __awaiter(this, arguments, void 0, function* (filePath, stableChecks = 10, // how many *consecutive* stable reads required
|
|
55
|
+
interval = 250 // ms between checks
|
|
56
|
+
) {
|
|
57
|
+
let lastSize = null;
|
|
58
|
+
let stableCount = 0;
|
|
59
|
+
while (stableCount < stableChecks) {
|
|
60
|
+
let stat;
|
|
61
|
+
try {
|
|
62
|
+
stat = yield node_fs_1.promises.stat(filePath);
|
|
63
|
+
}
|
|
64
|
+
catch (_a) {
|
|
65
|
+
// file might not exist yet – reset
|
|
66
|
+
lastSize = null;
|
|
67
|
+
stableCount = 0;
|
|
68
|
+
yield new Promise((res) => setTimeout(res, interval));
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const size = stat.size;
|
|
72
|
+
if (lastSize !== null && size === lastSize) {
|
|
73
|
+
stableCount++;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
stableCount = 0; // reset if changed
|
|
77
|
+
}
|
|
78
|
+
lastSize = size;
|
|
79
|
+
yield new Promise((res) => setTimeout(res, interval));
|
|
80
|
+
}
|
|
81
|
+
return true; // stable!
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const handleArchive = (dirPath, mizpath) => {
|
|
85
|
+
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
const archive = (0, archiver_1.default)("zip", { zlib: { level: 9 } });
|
|
87
|
+
const output = node_fs_1.default.createWriteStream(mizpath);
|
|
88
|
+
// Handle events
|
|
89
|
+
output.on('close', function () {
|
|
90
|
+
console.log(`Archive created successfully at ${mizpath}, total bytes: ${archive.pointer()}`);
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
archive.on('error', function (err) {
|
|
94
|
+
throw err;
|
|
95
|
+
});
|
|
96
|
+
// Pipe archive data to the file
|
|
97
|
+
archive.pipe(output);
|
|
98
|
+
// Append directory
|
|
99
|
+
archive.directory(dirPath, false); // false = no root folder in zip
|
|
100
|
+
// Finalize the archive
|
|
101
|
+
yield archive.finalize();
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
exports.handleArchive = handleArchive;
|
|
105
|
+
const unpackMiz = (path, outPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
+
try {
|
|
107
|
+
console.log('decompressing');
|
|
108
|
+
const result = yield (0, decompress_1.default)(path, outPath);
|
|
109
|
+
if (!result.length) {
|
|
110
|
+
throw new Error('Decompression yielded no results, something is wrong with the .miz');
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.error(err);
|
|
116
|
+
throw err;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
exports.unpackMiz = unpackMiz;
|
|
110
120
|
//# sourceMappingURL=compression.js.map
|
package/dist/compression.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compression.js","sourceRoot":"","sources":["../src/compression.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compression.js","sourceRoot":"","sources":["../src/compression.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,kCAoCC;AAxCD,mDAAuC;AACvC,wDAAgC;AAChC,4DAAoC;AAEpC,SAAsB,WAAW;yDAC7B,QAAgB,EAChB,YAAY,GAAG,EAAE,EAAO,+CAA+C;IACvE,QAAQ,GAAG,GAAG,CAAS,oBAAoB;;QAG3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