@notask/unity-cli-tools 1.0.7-rc.1 → 1.1.0-rc.1
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/CHANGELOG.md +16 -1
- package/README.md +52 -0
- package/dist/cjs/events/hubEventEmitter.js +54 -0
- package/dist/cjs/events/hubEventParser.js +44 -0
- package/dist/cjs/types/unity.js +21 -1
- package/dist/cjs/unityHub.js +13 -21
- package/dist/esm/events/hubEventEmitter.d.ts +20 -0
- package/dist/esm/events/hubEventEmitter.js +50 -0
- package/dist/esm/events/hubEventParser.d.ts +6 -0
- package/dist/esm/events/hubEventParser.js +40 -0
- package/dist/esm/types/unity.d.ts +24 -0
- package/dist/esm/types/unity.js +20 -0
- package/dist/esm/unityHub.d.ts +3 -2
- package/dist/esm/unityHub.js +13 -21
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
# [1.1.0-rc.1](https://github.com/NoTaskStudios/unity-cli-tools/compare/1.0.7...1.1.0-rc.1) (2025-05-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* access modifiers and catch execa errors ([78c7d26](https://github.com/NoTaskStudios/unity-cli-tools/commit/78c7d26e863fecfe6518384335f9f403cf4144e7))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **Hub:** Added Error track event for installers ([7333430](https://github.com/NoTaskStudios/unity-cli-tools/commit/7333430a87b2a306e0d9915f2d5bb60baf538698))
|
|
12
|
+
* **Hub:** Added install event emitter for hub events ([cb26730](https://github.com/NoTaskStudios/unity-cli-tools/commit/cb26730c94840218dbc6300573dd601003632a33))
|
|
13
|
+
* **Hub:** Added installer std parser to event emitter ([ffe57b4](https://github.com/NoTaskStudios/unity-cli-tools/commit/ffe57b4b09a1d921573351526df5e887b23875cf))
|
|
14
|
+
* **Hub:** Added types for installer event emitter ([f25e486](https://github.com/NoTaskStudios/unity-cli-tools/commit/f25e48611e0d7b8b49aafea4f0900f65e42cc079))
|
|
15
|
+
|
|
16
|
+
## [1.0.7](https://github.com/NoTaskStudios/unity-cli-tools/compare/1.0.6...1.0.7) (2025-05-03)
|
|
2
17
|
|
|
3
18
|
|
|
4
19
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -69,6 +69,34 @@ await UnityHub.addEditor("2022.3.60f1", undefined, [UnityModules.AndroidBuildSup
|
|
|
69
69
|
await UnityHub.addModule("2022.3.60f1", [UnityModules.IOSBuildSupport]);
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
+
### Installation Events
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { UnityHub, UnityModules, InstallerEventType } from "unity-cli-tools";
|
|
76
|
+
|
|
77
|
+
// Install with event tracking (addEditor returns an event emitter)
|
|
78
|
+
const installer = await UnityHub.addEditor("2022.3.60f1");
|
|
79
|
+
|
|
80
|
+
// Get a promise that resolves when installation completes
|
|
81
|
+
const installation = installer.completed;
|
|
82
|
+
|
|
83
|
+
// Or listen to specific events
|
|
84
|
+
installer.on(InstallerEventType.Progress, (events) => {
|
|
85
|
+
console.log("Progress:", events.map(e => `${e.module}: ${e.status} ${e.progress || 0}%`));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
installer.on(InstallerEventType.Error, (error) => {
|
|
89
|
+
console.error("Installation error:", error);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
installer.on(InstallerEventType.Completed, (events) => {
|
|
93
|
+
console.log("Installation completed!");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Cancel installation if needed
|
|
97
|
+
installer.Cancel();
|
|
98
|
+
```
|
|
99
|
+
|
|
72
100
|
### Projects Management
|
|
73
101
|
|
|
74
102
|
```typescript
|
|
@@ -225,6 +253,30 @@ console.log(executionResult);
|
|
|
225
253
|
| `ChineseTraditional` | Traditional Chinese language pack |
|
|
226
254
|
| `Chinese` | Chinese language pack (legacy) |
|
|
227
255
|
|
|
256
|
+
### InstallerStatus
|
|
257
|
+
|
|
258
|
+
| Constant | Description |
|
|
259
|
+
| ------------------ | ------------------------------- |
|
|
260
|
+
| `Queued` | Queued for download |
|
|
261
|
+
| `Validating` | Validating download |
|
|
262
|
+
| `InProgress` | Installation in progress |
|
|
263
|
+
| `Downloading` | Downloading installation files |
|
|
264
|
+
| `QueuedInstall` | Queued for install |
|
|
265
|
+
| `ValidatingInstall`| Validating installation |
|
|
266
|
+
| `Installing` | Installing |
|
|
267
|
+
| `Verifying` | Verifying installation |
|
|
268
|
+
| `Installed` | Installed successfully |
|
|
269
|
+
| `Error` | Installation error |
|
|
270
|
+
|
|
271
|
+
### InstallerEventType
|
|
272
|
+
|
|
273
|
+
| Constant | Description |
|
|
274
|
+
| ------------ | ------------------------------------------- |
|
|
275
|
+
| `Progress` | Installation progress update event |
|
|
276
|
+
| `Error` | Installation error event |
|
|
277
|
+
| `Completed` | Installation completed successfully event |
|
|
278
|
+
| `Cancelled` | Installation cancelled by user event |
|
|
279
|
+
|
|
228
280
|
|
|
229
281
|
## Configuration
|
|
230
282
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnityHubInstallerEvent = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const unity_ts_1 = require("../types/unity.js");
|
|
6
|
+
const hubEventParser_ts_1 = require("./hubEventParser.js");
|
|
7
|
+
class UnityHubInstallerEvent extends events_1.EventEmitter {
|
|
8
|
+
#moduleTracker = new Map();
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
completed = new Promise((resolve, reject) => {
|
|
13
|
+
this.on(unity_ts_1.InstallerEventType.Completed, (events) => resolve(events));
|
|
14
|
+
this.on(unity_ts_1.InstallerEventType.Error, (error) => reject(error));
|
|
15
|
+
this.on(unity_ts_1.InstallerEventType.Cancelled, (events) => reject(new Error("Cancelled")));
|
|
16
|
+
});
|
|
17
|
+
Progress(raw) {
|
|
18
|
+
const events = hubEventParser_ts_1.UnityHubEventParser.parseUnityHubEvent(raw);
|
|
19
|
+
if (events.length === 0)
|
|
20
|
+
return;
|
|
21
|
+
this.#Error(events);
|
|
22
|
+
const progressEvents = events.filter((e) => e.status !== unity_ts_1.InstallerStatus.Error);
|
|
23
|
+
if (progressEvents.length === 0)
|
|
24
|
+
return;
|
|
25
|
+
this.emit(unity_ts_1.InstallerEventType.Progress, progressEvents);
|
|
26
|
+
this.#updateModuleTracker(events);
|
|
27
|
+
this.#Complete(progressEvents);
|
|
28
|
+
}
|
|
29
|
+
#Error(events) {
|
|
30
|
+
const errorEvents = events.filter((e) => e.status === unity_ts_1.InstallerStatus.Error);
|
|
31
|
+
if (errorEvents.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
this.emit(unity_ts_1.InstallerEventType.Error, errorEvents);
|
|
34
|
+
}
|
|
35
|
+
#Complete(events) {
|
|
36
|
+
const installed = events.filter((e) => e.status === unity_ts_1.InstallerStatus.Installed);
|
|
37
|
+
if (installed.length > 0 && installed.length === events.length) {
|
|
38
|
+
this.emit(unity_ts_1.InstallerEventType.Completed, installed);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
Cancel() {
|
|
42
|
+
this.#moduleTracker.clear();
|
|
43
|
+
this.#Cancelled([]);
|
|
44
|
+
}
|
|
45
|
+
#Cancelled(event) {
|
|
46
|
+
this.emit(unity_ts_1.InstallerEventType.Cancelled, event);
|
|
47
|
+
}
|
|
48
|
+
#updateModuleTracker(events) {
|
|
49
|
+
for (const event of events) {
|
|
50
|
+
this.#moduleTracker.set(event.module, event.status);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.UnityHubInstallerEvent = UnityHubInstallerEvent;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnityHubEventParser = void 0;
|
|
4
|
+
const unity_ts_1 = require("../types/unity.js");
|
|
5
|
+
class UnityHubEventParser {
|
|
6
|
+
static errorPatterns = [/Error:.*/];
|
|
7
|
+
static parseUnityHubEvent(event) {
|
|
8
|
+
const events = [];
|
|
9
|
+
const lines = event.split("\n");
|
|
10
|
+
for (const line of lines) {
|
|
11
|
+
const errorLine = this.checkForErrors(line);
|
|
12
|
+
if (errorLine) {
|
|
13
|
+
events.push(errorLine);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const pattern = /^\[(?<module>[^\]]+)\]\s+(?<status>.+?)(?:(?:\s+(?<progress>\d+(?:\.\d+)?))%)?\.*$/;
|
|
18
|
+
for (const line of lines) {
|
|
19
|
+
const match = line.match(pattern);
|
|
20
|
+
if (match?.groups) {
|
|
21
|
+
const { module, status, progress } = match.groups;
|
|
22
|
+
events.push({
|
|
23
|
+
module: module.trim(),
|
|
24
|
+
status: status.replace(/\.\.\.$/, "").trim(),
|
|
25
|
+
progress: progress ? parseFloat(progress) : status !== unity_ts_1.InstallerStatus.Downloading ? null : 0,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return events;
|
|
30
|
+
}
|
|
31
|
+
static checkForErrors(line) {
|
|
32
|
+
for (const pattern of this.errorPatterns) {
|
|
33
|
+
if (pattern.test(line)) {
|
|
34
|
+
return {
|
|
35
|
+
module: "UnityHub",
|
|
36
|
+
status: unity_ts_1.InstallerStatus.Error,
|
|
37
|
+
error: line.trim(),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.UnityHubEventParser = UnityHubEventParser;
|
package/dist/cjs/types/unity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnityBuildTarget = exports.TestMode = exports.EditorArchitecture = exports.UnityEditorLanguages = exports.UnityModules = void 0;
|
|
3
|
+
exports.InstallerEventType = exports.InstallerStatus = exports.UnityBuildTarget = exports.TestMode = exports.EditorArchitecture = exports.UnityEditorLanguages = exports.UnityModules = void 0;
|
|
4
4
|
var UnityModules;
|
|
5
5
|
(function (UnityModules) {
|
|
6
6
|
UnityModules["Documentation"] = "documentation";
|
|
@@ -59,3 +59,23 @@ var UnityBuildTarget;
|
|
|
59
59
|
UnityBuildTarget["PS5"] = "PS5";
|
|
60
60
|
UnityBuildTarget["VisionOS"] = "VisionOS";
|
|
61
61
|
})(UnityBuildTarget || (exports.UnityBuildTarget = UnityBuildTarget = {}));
|
|
62
|
+
var InstallerStatus;
|
|
63
|
+
(function (InstallerStatus) {
|
|
64
|
+
InstallerStatus["Queued"] = "queued for download";
|
|
65
|
+
InstallerStatus["Validating"] = "validating download";
|
|
66
|
+
InstallerStatus["InProgress"] = "in progress";
|
|
67
|
+
InstallerStatus["Downloading"] = "downloading";
|
|
68
|
+
InstallerStatus["QueuedInstall"] = "queued for install";
|
|
69
|
+
InstallerStatus["ValidatingInstall"] = "validation installation";
|
|
70
|
+
InstallerStatus["Installing"] = "installing";
|
|
71
|
+
InstallerStatus["Verifying"] = "verifying";
|
|
72
|
+
InstallerStatus["Installed"] = "installed successfully";
|
|
73
|
+
InstallerStatus["Error"] = "Error";
|
|
74
|
+
})(InstallerStatus || (exports.InstallerStatus = InstallerStatus = {}));
|
|
75
|
+
var InstallerEventType;
|
|
76
|
+
(function (InstallerEventType) {
|
|
77
|
+
InstallerEventType["Progress"] = "progress";
|
|
78
|
+
InstallerEventType["Error"] = "error";
|
|
79
|
+
InstallerEventType["Completed"] = "completed";
|
|
80
|
+
InstallerEventType["Cancelled"] = "cancelled";
|
|
81
|
+
})(InstallerEventType || (exports.InstallerEventType = InstallerEventType = {}));
|
package/dist/cjs/unityHub.js
CHANGED
|
@@ -9,6 +9,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
9
9
|
const unity_js_1 = require("./types/unity.js");
|
|
10
10
|
const commandExecutor_js_1 = require("./utils/commandExecutor.js");
|
|
11
11
|
const unity_changeset_1 = require("unity-changeset");
|
|
12
|
+
const hubEventEmitter_ts_1 = require("./events/hubEventEmitter.js");
|
|
12
13
|
class UnityHub {
|
|
13
14
|
static CONFIG_PATHS = {
|
|
14
15
|
win32: {
|
|
@@ -130,18 +131,14 @@ class UnityHub {
|
|
|
130
131
|
else {
|
|
131
132
|
throw new Error("No module IDs provided.");
|
|
132
133
|
}
|
|
133
|
-
const
|
|
134
|
+
const installerEmitter = new hubEventEmitter_ts_1.UnityHubInstallerEvent();
|
|
135
|
+
this.execUnityHubCommand(args, {
|
|
134
136
|
reject: false,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
onStdout: (data) => {
|
|
139
|
-
console.debug(`Unity Hub stdout: ${data}`);
|
|
140
|
-
},
|
|
137
|
+
onStdout: (data) => installerEmitter.Progress(data),
|
|
138
|
+
}).catch((error) => {
|
|
139
|
+
console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
|
|
141
140
|
});
|
|
142
|
-
|
|
143
|
-
console.warn(`Add module command warning/error: ${stderr}`);
|
|
144
|
-
}
|
|
141
|
+
return installerEmitter;
|
|
145
142
|
}
|
|
146
143
|
catch (error) {
|
|
147
144
|
console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
|
|
@@ -163,19 +160,14 @@ class UnityHub {
|
|
|
163
160
|
architecture = defaultArchitecture;
|
|
164
161
|
}
|
|
165
162
|
args.push("--architecture", architecture);
|
|
166
|
-
const
|
|
163
|
+
const installerEmitter = new hubEventEmitter_ts_1.UnityHubInstallerEvent();
|
|
164
|
+
this.execUnityHubCommand(args, {
|
|
167
165
|
reject: false,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
onStdout: (data) => {
|
|
172
|
-
console.debug(`Unity Hub stdout: ${data}`);
|
|
173
|
-
},
|
|
166
|
+
onStdout: (data) => installerEmitter.Progress(data),
|
|
167
|
+
}).catch((error) => {
|
|
168
|
+
console.error(`Error installing Unity ${version}:`, error);
|
|
174
169
|
});
|
|
175
|
-
|
|
176
|
-
throw new Error(`Error installing Unity ${version}: ${stderr}`);
|
|
177
|
-
}
|
|
178
|
-
console.debug(`Unity ${version}. ${stdout}`);
|
|
170
|
+
return installerEmitter;
|
|
179
171
|
}
|
|
180
172
|
catch (error) {
|
|
181
173
|
console.error(error);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { InstallerEventType, InstallerEvent } from "../types/unity.ts";
|
|
3
|
+
export interface InstallerEmitter extends EventEmitter {
|
|
4
|
+
on(event: InstallerEventType.Progress, listener: (info: InstallerEvent[]) => void): this;
|
|
5
|
+
on(event: InstallerEventType.Error, listener: (error: Error) => void): this;
|
|
6
|
+
on(event: InstallerEventType.Completed, listener: (info: InstallerEvent[]) => void): this;
|
|
7
|
+
on(event: InstallerEventType.Cancelled, listener: (info: InstallerEvent[]) => void): this;
|
|
8
|
+
emit(event: InstallerEventType.Progress, info: InstallerEvent[]): boolean;
|
|
9
|
+
emit(event: InstallerEventType.Error, info: InstallerEvent[]): boolean;
|
|
10
|
+
emit(event: InstallerEventType.Completed, info: InstallerEvent[]): boolean;
|
|
11
|
+
emit(event: InstallerEventType.Cancelled, info: InstallerEvent[]): boolean;
|
|
12
|
+
readonly completed: Promise<InstallerEvent[]>;
|
|
13
|
+
}
|
|
14
|
+
export declare class UnityHubInstallerEvent extends EventEmitter implements InstallerEmitter {
|
|
15
|
+
#private;
|
|
16
|
+
constructor();
|
|
17
|
+
completed: Promise<InstallerEvent[]>;
|
|
18
|
+
Progress(raw: string): void;
|
|
19
|
+
Cancel(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { InstallerEventType, InstallerStatus } from "../types/unity.js";
|
|
3
|
+
import { UnityHubEventParser } from "./hubEventParser.js";
|
|
4
|
+
export class UnityHubInstallerEvent extends EventEmitter {
|
|
5
|
+
#moduleTracker = new Map();
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
}
|
|
9
|
+
completed = new Promise((resolve, reject) => {
|
|
10
|
+
this.on(InstallerEventType.Completed, (events) => resolve(events));
|
|
11
|
+
this.on(InstallerEventType.Error, (error) => reject(error));
|
|
12
|
+
this.on(InstallerEventType.Cancelled, (events) => reject(new Error("Cancelled")));
|
|
13
|
+
});
|
|
14
|
+
Progress(raw) {
|
|
15
|
+
const events = UnityHubEventParser.parseUnityHubEvent(raw);
|
|
16
|
+
if (events.length === 0)
|
|
17
|
+
return;
|
|
18
|
+
this.#Error(events);
|
|
19
|
+
const progressEvents = events.filter((e) => e.status !== InstallerStatus.Error);
|
|
20
|
+
if (progressEvents.length === 0)
|
|
21
|
+
return;
|
|
22
|
+
this.emit(InstallerEventType.Progress, progressEvents);
|
|
23
|
+
this.#updateModuleTracker(events);
|
|
24
|
+
this.#Complete(progressEvents);
|
|
25
|
+
}
|
|
26
|
+
#Error(events) {
|
|
27
|
+
const errorEvents = events.filter((e) => e.status === InstallerStatus.Error);
|
|
28
|
+
if (errorEvents.length === 0)
|
|
29
|
+
return;
|
|
30
|
+
this.emit(InstallerEventType.Error, errorEvents);
|
|
31
|
+
}
|
|
32
|
+
#Complete(events) {
|
|
33
|
+
const installed = events.filter((e) => e.status === InstallerStatus.Installed);
|
|
34
|
+
if (installed.length > 0 && installed.length === events.length) {
|
|
35
|
+
this.emit(InstallerEventType.Completed, installed);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Cancel() {
|
|
39
|
+
this.#moduleTracker.clear();
|
|
40
|
+
this.#Cancelled([]);
|
|
41
|
+
}
|
|
42
|
+
#Cancelled(event) {
|
|
43
|
+
this.emit(InstallerEventType.Cancelled, event);
|
|
44
|
+
}
|
|
45
|
+
#updateModuleTracker(events) {
|
|
46
|
+
for (const event of events) {
|
|
47
|
+
this.#moduleTracker.set(event.module, event.status);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { InstallerStatus } from "../types/unity.js";
|
|
2
|
+
export class UnityHubEventParser {
|
|
3
|
+
static errorPatterns = [/Error:.*/];
|
|
4
|
+
static parseUnityHubEvent(event) {
|
|
5
|
+
const events = [];
|
|
6
|
+
const lines = event.split("\n");
|
|
7
|
+
for (const line of lines) {
|
|
8
|
+
const errorLine = this.checkForErrors(line);
|
|
9
|
+
if (errorLine) {
|
|
10
|
+
events.push(errorLine);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const pattern = /^\[(?<module>[^\]]+)\]\s+(?<status>.+?)(?:(?:\s+(?<progress>\d+(?:\.\d+)?))%)?\.*$/;
|
|
15
|
+
for (const line of lines) {
|
|
16
|
+
const match = line.match(pattern);
|
|
17
|
+
if (match?.groups) {
|
|
18
|
+
const { module, status, progress } = match.groups;
|
|
19
|
+
events.push({
|
|
20
|
+
module: module.trim(),
|
|
21
|
+
status: status.replace(/\.\.\.$/, "").trim(),
|
|
22
|
+
progress: progress ? parseFloat(progress) : status !== InstallerStatus.Downloading ? null : 0,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return events;
|
|
27
|
+
}
|
|
28
|
+
static checkForErrors(line) {
|
|
29
|
+
for (const pattern of this.errorPatterns) {
|
|
30
|
+
if (pattern.test(line)) {
|
|
31
|
+
return {
|
|
32
|
+
module: "UnityHub",
|
|
33
|
+
status: InstallerStatus.Error,
|
|
34
|
+
error: line.trim(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -75,3 +75,27 @@ export declare enum UnityBuildTarget {
|
|
|
75
75
|
PS5 = "PS5",
|
|
76
76
|
VisionOS = "VisionOS"
|
|
77
77
|
}
|
|
78
|
+
export declare enum InstallerStatus {
|
|
79
|
+
Queued = "queued for download",
|
|
80
|
+
Validating = "validating download",
|
|
81
|
+
InProgress = "in progress",
|
|
82
|
+
Downloading = "downloading",
|
|
83
|
+
QueuedInstall = "queued for install",
|
|
84
|
+
ValidatingInstall = "validation installation",
|
|
85
|
+
Installing = "installing",
|
|
86
|
+
Verifying = "verifying",
|
|
87
|
+
Installed = "installed successfully",
|
|
88
|
+
Error = "Error"
|
|
89
|
+
}
|
|
90
|
+
export interface InstallerEvent {
|
|
91
|
+
module: string;
|
|
92
|
+
status: InstallerStatus;
|
|
93
|
+
progress?: number | null;
|
|
94
|
+
error?: string | null;
|
|
95
|
+
}
|
|
96
|
+
export declare enum InstallerEventType {
|
|
97
|
+
Progress = "progress",
|
|
98
|
+
Error = "error",
|
|
99
|
+
Completed = "completed",
|
|
100
|
+
Cancelled = "cancelled"
|
|
101
|
+
}
|
package/dist/esm/types/unity.js
CHANGED
|
@@ -56,3 +56,23 @@ export var UnityBuildTarget;
|
|
|
56
56
|
UnityBuildTarget["PS5"] = "PS5";
|
|
57
57
|
UnityBuildTarget["VisionOS"] = "VisionOS";
|
|
58
58
|
})(UnityBuildTarget || (UnityBuildTarget = {}));
|
|
59
|
+
export var InstallerStatus;
|
|
60
|
+
(function (InstallerStatus) {
|
|
61
|
+
InstallerStatus["Queued"] = "queued for download";
|
|
62
|
+
InstallerStatus["Validating"] = "validating download";
|
|
63
|
+
InstallerStatus["InProgress"] = "in progress";
|
|
64
|
+
InstallerStatus["Downloading"] = "downloading";
|
|
65
|
+
InstallerStatus["QueuedInstall"] = "queued for install";
|
|
66
|
+
InstallerStatus["ValidatingInstall"] = "validation installation";
|
|
67
|
+
InstallerStatus["Installing"] = "installing";
|
|
68
|
+
InstallerStatus["Verifying"] = "verifying";
|
|
69
|
+
InstallerStatus["Installed"] = "installed successfully";
|
|
70
|
+
InstallerStatus["Error"] = "Error";
|
|
71
|
+
})(InstallerStatus || (InstallerStatus = {}));
|
|
72
|
+
export var InstallerEventType;
|
|
73
|
+
(function (InstallerEventType) {
|
|
74
|
+
InstallerEventType["Progress"] = "progress";
|
|
75
|
+
InstallerEventType["Error"] = "error";
|
|
76
|
+
InstallerEventType["Completed"] = "completed";
|
|
77
|
+
InstallerEventType["Cancelled"] = "cancelled";
|
|
78
|
+
})(InstallerEventType || (InstallerEventType = {}));
|
package/dist/esm/unityHub.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EditorArchitecture, ModuleId, UnityInstallations } from "./types/unity.js";
|
|
2
2
|
import { CommandOptions, CommandResult } from "./utils/commandExecutor.js";
|
|
3
|
+
import { UnityHubInstallerEvent } from "./events/hubEventEmitter.ts";
|
|
3
4
|
declare class UnityHub {
|
|
4
5
|
private static CONFIG_PATHS;
|
|
5
6
|
static getUnityHubPath(): string;
|
|
@@ -8,8 +9,8 @@ declare class UnityHub {
|
|
|
8
9
|
static getInstallPath(): Promise<string>;
|
|
9
10
|
static setInstallPath(path: string): Promise<void>;
|
|
10
11
|
static getUnityInstallations(filter?: string): Promise<UnityInstallations>;
|
|
11
|
-
static addModule(editorVersion: string, modules: ModuleId[], childModules?: boolean): Promise<
|
|
12
|
-
static addEditor(version: string, modules?: ModuleId[], architecture?: EditorArchitecture): Promise<
|
|
12
|
+
static addModule(editorVersion: string, modules: ModuleId[], childModules?: boolean): Promise<UnityHubInstallerEvent>;
|
|
13
|
+
static addEditor(version: string, modules?: ModuleId[], architecture?: EditorArchitecture): Promise<UnityHubInstallerEvent>;
|
|
13
14
|
static getProjects(): Promise<{
|
|
14
15
|
name: string;
|
|
15
16
|
path: string;
|
package/dist/esm/unityHub.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { EditorArchitecture, } from "./types/unity.js";
|
|
5
5
|
import { executeCommand } from "./utils/commandExecutor.js";
|
|
6
6
|
import { getUnityChangeset } from "unity-changeset";
|
|
7
|
+
import { UnityHubInstallerEvent } from "./events/hubEventEmitter.js";
|
|
7
8
|
class UnityHub {
|
|
8
9
|
static CONFIG_PATHS = {
|
|
9
10
|
win32: {
|
|
@@ -125,18 +126,14 @@ class UnityHub {
|
|
|
125
126
|
else {
|
|
126
127
|
throw new Error("No module IDs provided.");
|
|
127
128
|
}
|
|
128
|
-
const
|
|
129
|
+
const installerEmitter = new UnityHubInstallerEvent();
|
|
130
|
+
this.execUnityHubCommand(args, {
|
|
129
131
|
reject: false,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
onStdout: (data) => {
|
|
134
|
-
console.debug(`Unity Hub stdout: ${data}`);
|
|
135
|
-
},
|
|
132
|
+
onStdout: (data) => installerEmitter.Progress(data),
|
|
133
|
+
}).catch((error) => {
|
|
134
|
+
console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
|
|
136
135
|
});
|
|
137
|
-
|
|
138
|
-
console.warn(`Add module command warning/error: ${stderr}`);
|
|
139
|
-
}
|
|
136
|
+
return installerEmitter;
|
|
140
137
|
}
|
|
141
138
|
catch (error) {
|
|
142
139
|
console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
|
|
@@ -158,19 +155,14 @@ class UnityHub {
|
|
|
158
155
|
architecture = defaultArchitecture;
|
|
159
156
|
}
|
|
160
157
|
args.push("--architecture", architecture);
|
|
161
|
-
const
|
|
158
|
+
const installerEmitter = new UnityHubInstallerEvent();
|
|
159
|
+
this.execUnityHubCommand(args, {
|
|
162
160
|
reject: false,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
onStdout: (data) => {
|
|
167
|
-
console.debug(`Unity Hub stdout: ${data}`);
|
|
168
|
-
},
|
|
161
|
+
onStdout: (data) => installerEmitter.Progress(data),
|
|
162
|
+
}).catch((error) => {
|
|
163
|
+
console.error(`Error installing Unity ${version}:`, error);
|
|
169
164
|
});
|
|
170
|
-
|
|
171
|
-
throw new Error(`Error installing Unity ${version}: ${stderr}`);
|
|
172
|
-
}
|
|
173
|
-
console.debug(`Unity ${version}. ${stdout}`);
|
|
165
|
+
return installerEmitter;
|
|
174
166
|
}
|
|
175
167
|
catch (error) {
|
|
176
168
|
console.error(error);
|