@notask/unity-cli-tools 1.2.0-rc.1 → 2.0.0

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.
Files changed (64) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/CHANGELOG.md +164 -164
  3. package/LICENSE +23 -23
  4. package/README.md +809 -347
  5. package/dist/cjs/errors/Result.js +76 -0
  6. package/dist/cjs/errors/UnityError.js +77 -0
  7. package/dist/cjs/errors/index.js +18 -0
  8. package/dist/cjs/events/hubEventEmitter.js +16 -16
  9. package/dist/cjs/events/hubEventParser.js +97 -27
  10. package/dist/cjs/events/patterns/implementations/bracketModulePattern.js +57 -0
  11. package/dist/cjs/events/patterns/implementations/errorPattern.js +99 -0
  12. package/dist/cjs/events/patterns/implementations/fallbackPattern.js +63 -0
  13. package/dist/cjs/events/patterns/implementations/index.js +9 -0
  14. package/dist/cjs/events/patterns/index.js +23 -0
  15. package/dist/cjs/events/patterns/patternRegistry.js +69 -0
  16. package/dist/cjs/events/patterns/statusNormalizer.js +280 -0
  17. package/dist/cjs/events/patterns/types.js +2 -0
  18. package/dist/cjs/index.js +8 -11
  19. package/dist/cjs/unityEditor.js +182 -230
  20. package/dist/cjs/unityHub.js +110 -85
  21. package/dist/cjs/utils/commandExecutor.js +8 -9
  22. package/dist/esm/errors/Result.d.ts +21 -0
  23. package/dist/esm/errors/Result.js +63 -0
  24. package/dist/esm/errors/UnityError.d.ts +36 -0
  25. package/dist/esm/errors/UnityError.js +64 -0
  26. package/dist/esm/errors/index.d.ts +2 -0
  27. package/dist/esm/errors/index.js +2 -0
  28. package/dist/esm/events/hubEventEmitter.d.ts +1 -1
  29. package/dist/esm/events/hubEventParser.d.ts +17 -3
  30. package/dist/esm/events/hubEventParser.js +97 -27
  31. package/dist/esm/events/patterns/implementations/bracketModulePattern.d.ts +11 -0
  32. package/dist/esm/events/patterns/implementations/bracketModulePattern.js +53 -0
  33. package/dist/esm/events/patterns/implementations/errorPattern.d.ts +22 -0
  34. package/dist/esm/events/patterns/implementations/errorPattern.js +95 -0
  35. package/dist/esm/events/patterns/implementations/fallbackPattern.d.ts +13 -0
  36. package/dist/esm/events/patterns/implementations/fallbackPattern.js +59 -0
  37. package/dist/esm/events/patterns/implementations/index.d.ts +3 -0
  38. package/dist/esm/events/patterns/implementations/index.js +3 -0
  39. package/dist/esm/events/patterns/index.d.ts +4 -0
  40. package/dist/esm/events/patterns/index.js +4 -0
  41. package/dist/esm/events/patterns/patternRegistry.d.ts +14 -0
  42. package/dist/esm/events/patterns/patternRegistry.js +65 -0
  43. package/dist/esm/events/patterns/statusNormalizer.d.ts +15 -0
  44. package/dist/esm/events/patterns/statusNormalizer.js +276 -0
  45. package/dist/esm/events/patterns/types.d.ts +30 -0
  46. package/dist/esm/events/patterns/types.js +1 -0
  47. package/dist/esm/index.d.ts +5 -6
  48. package/dist/esm/index.js +1 -2
  49. package/dist/esm/unityEditor.d.ts +11 -15
  50. package/dist/esm/unityEditor.js +196 -244
  51. package/dist/esm/unityHub.d.ts +13 -11
  52. package/dist/esm/unityHub.js +108 -83
  53. package/dist/esm/utils/commandExecutor.d.ts +4 -3
  54. package/dist/esm/utils/commandExecutor.js +8 -9
  55. package/package.json +70 -70
  56. package/sandbox/index.js +51 -0
  57. package/sandbox/node_modules/.package-lock.json +10495 -0
  58. package/sandbox/package.json +13 -0
  59. package/dist/cjs/configs/unityConfig.js +0 -74
  60. package/dist/cjs/unityTemplates.js +0 -29
  61. package/dist/esm/configs/unityConfig.d.ts +0 -25
  62. package/dist/esm/configs/unityConfig.js +0 -68
  63. package/dist/esm/unityTemplates.d.ts +0 -10
  64. package/dist/esm/unityTemplates.js +0 -24
@@ -1,17 +1,29 @@
1
+ import os from "os";
1
2
  import fs from "fs-extra";
2
3
  import path from "path";
3
4
  import { TestMode } from "./types/unity.js";
4
5
  import { executeCommand } from "./utils/commandExecutor.js";
5
6
  import { redactSensitiveArgs } from "./utils/security.js";
6
- import { UnityConfig } from "./configs/unityConfig.js";
7
+ import { ok, err, UnityEditorNotFoundError, UnityCommandError, UnityTestError, UnityLicenseError, UnityPackageError, UnityProjectError, } from "./errors/index.js";
7
8
  class UnityEditor {
8
- static unityConfig = UnityConfig.getPlatformConfig().editor;
9
+ static UNITY_PATHS = {
10
+ win32: {
11
+ base: "C:/Program Files/Unity/Hub/Editor",
12
+ executable: "Editor/Unity.exe",
13
+ },
14
+ darwin: {
15
+ base: "/Applications/Unity/Hub/Editor",
16
+ executable: "Unity.app/Contents/MacOS/Unity",
17
+ },
18
+ linux: {
19
+ base: "/opt/unity/editor",
20
+ executable: "Editor/Unity",
21
+ },
22
+ };
9
23
  static getUnityExecutablePath(version) {
10
- const unityPath = path.join(this.unityConfig.base, version, this.unityConfig.executable);
11
- return unityPath;
12
- }
13
- static getUnityTemplatesPath(version) {
14
- const unityPath = path.join(this.unityConfig.base, version, this.unityConfig.projectTemplates);
24
+ const platform = os.platform();
25
+ const unityConfig = UnityEditor.UNITY_PATHS[platform];
26
+ const unityPath = path.join(unityConfig.base, version, unityConfig.executable);
15
27
  return unityPath;
16
28
  }
17
29
  static async isUnityVersionInstalled(version) {
@@ -25,276 +37,216 @@ class UnityEditor {
25
37
  }
26
38
  }
27
39
  static async execUnityEditorCommand(editorInfo, args, options = {}) {
28
- try {
29
- const unityPath = this.getUnityExecutablePath(editorInfo.version);
30
- if (!fs.existsSync(unityPath)) {
31
- return {
32
- success: false,
33
- stdout: "",
34
- stderr: `Unity executable not found at path: ${unityPath}`,
35
- exitCode: -1,
36
- };
37
- }
38
- const editorArgs = [...args];
39
- const redactedArgs = redactSensitiveArgs(editorArgs);
40
- console.debug(`Executing Unity Editor command: ${unityPath} ${redactedArgs.join(" ")}`);
41
- return await executeCommand(unityPath, editorArgs, options);
42
- }
43
- catch (error) {
44
- console.error("Error executing Unity Editor command:", error);
45
- return {
46
- success: false,
47
- stdout: "",
48
- stderr: String(error),
49
- exitCode: -1,
50
- };
51
- }
40
+ const unityPath = this.getUnityExecutablePath(editorInfo.version);
41
+ if (!fs.existsSync(unityPath)) {
42
+ return err(new UnityEditorNotFoundError(editorInfo.version, unityPath));
43
+ }
44
+ const editorArgs = [...args];
45
+ const redactedArgs = redactSensitiveArgs(editorArgs);
46
+ console.debug(`Executing Unity Editor command: ${unityPath} ${redactedArgs.join(" ")}`);
47
+ return await executeCommand(unityPath, editorArgs, options);
52
48
  }
53
49
  static async executeMethod(projectInfo, method, args = [], options = {}) {
54
- try {
55
- console.debug(`Executing method ${method} in Unity Editor`);
56
- const unityPath = this.getUnityExecutablePath(projectInfo.editorVersion);
57
- const editorArgs = ["-projectPath", projectInfo.projectPath, "-executeMethod", method, ...args];
58
- const { stdout, stderr } = await this.execUnityEditorCommand({ version: projectInfo.editorVersion, path: unityPath }, editorArgs, options);
59
- if (stderr) {
60
- console.error(`Error executing method: ${stderr}`);
61
- return {
62
- success: false,
63
- stdout: "",
64
- stderr: stderr,
65
- exitCode: -1,
66
- };
67
- }
68
- return {
69
- success: true,
70
- stdout: stdout,
71
- stderr: "",
72
- exitCode: 0,
73
- };
74
- }
75
- catch (error) {
76
- console.error("Error executing method:", error);
77
- return {
78
- success: false,
79
- stdout: "",
80
- stderr: String(error),
81
- exitCode: -1,
82
- };
83
- }
50
+ console.debug(`Executing method ${method} in Unity Editor`);
51
+ const unityPath = this.getUnityExecutablePath(projectInfo.editorVersion);
52
+ const editorArgs = ["-projectPath", projectInfo.projectPath, "-executeMethod", method, ...args];
53
+ const result = await this.execUnityEditorCommand({ version: projectInfo.editorVersion, path: unityPath }, editorArgs, options);
54
+ if (!result.success) {
55
+ console.error(`Error executing method: ${result.error.message}`);
56
+ return result;
57
+ }
58
+ if (result.value.stderr) {
59
+ console.error(`Error executing method: ${result.value.stderr}`);
60
+ return err(new UnityCommandError(`Error executing method ${method}: ${result.value.stderr}`, result.value.stdout, result.value.stderr, result.value.exitCode, { method, projectInfo }));
61
+ }
62
+ return result;
84
63
  }
85
64
  static async runTests(projectInfo, testPlatform = TestMode.EditMode, testCategory) {
86
- try {
87
- console.debug(`Running ${testPlatform} tests for project ${testCategory ? ` in category ${testCategory}` : ""}`);
88
- const args = [
89
- "-batchmode",
90
- "-quit",
91
- "-projectPath",
92
- projectInfo.projectPath,
93
- "-runTests",
94
- "-testPlatform",
65
+ console.debug(`Running ${testPlatform} tests for project${testCategory ? ` in category ${testCategory}` : ""}`);
66
+ const args = [
67
+ "-batchmode",
68
+ "-quit",
69
+ "-projectPath",
70
+ projectInfo.projectPath,
71
+ "-runTests",
72
+ "-testPlatform",
73
+ testPlatform,
74
+ ];
75
+ if (testCategory) {
76
+ args.push("-testCategory", testCategory);
77
+ }
78
+ const editorInfo = { version: projectInfo.editorVersion };
79
+ const result = await this.execUnityEditorCommand(editorInfo, args, {
80
+ reject: false,
81
+ });
82
+ if (!result.success) {
83
+ return result;
84
+ }
85
+ const { stdout, stderr } = result.value;
86
+ const testsFailed = stdout.includes("Some tests failed") || stdout.includes("Test run failed") || stderr.includes("Test run failed");
87
+ if (testsFailed) {
88
+ return err(new UnityTestError("Some tests failed", stdout, {
89
+ projectInfo,
95
90
  testPlatform,
96
- ];
97
- if (testCategory) {
98
- args.push("-testCategory", testCategory);
99
- }
100
- const editorInfo = { version: projectInfo.editorVersion };
101
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
102
- reject: false,
103
- });
104
- const testsFailed = stdout.includes("Some tests failed") ||
105
- stdout.includes("Test run failed") ||
106
- stderr.includes("Test run failed");
107
- return {
108
- success: !testsFailed,
109
- output: stdout,
110
- };
111
- }
112
- catch (error) {
113
- console.error("Error running tests:", error);
114
- return {
115
- success: false,
116
- output: String(error),
117
- };
91
+ testCategory,
92
+ }));
118
93
  }
94
+ return ok(stdout);
119
95
  }
120
96
  static async activateLicense(projectInfo, serial, username, password) {
121
- try {
122
- console.debug(`Activating Unity license for version ${projectInfo.editorVersion}`);
123
- const args = ["-quit", "-serial", serial, "-username", username, "-password", password];
124
- const editorInfo = { version: projectInfo.editorVersion };
125
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
126
- reject: false,
127
- });
128
- const activationSuccessful = stdout.includes("successfully activated") ||
129
- (!stdout.includes("License activation failed") && !stderr.includes("License activation failed"));
130
- if (activationSuccessful) {
131
- console.debug(`Successfully activated license for Unity ${projectInfo.editorVersion}`);
132
- return true;
133
- }
134
- else {
135
- console.error(`Failed to activate license: ${stderr || stdout}`);
136
- return false;
137
- }
138
- }
139
- catch (error) {
140
- console.error("Error activating license:", error);
141
- return false;
142
- }
97
+ console.debug(`Activating Unity license for version ${projectInfo.editorVersion}`);
98
+ const args = ["-quit", "-serial", serial, "-username", username, "-password", password];
99
+ const editorInfo = { version: projectInfo.editorVersion };
100
+ const result = await this.execUnityEditorCommand(editorInfo, args, {
101
+ reject: false,
102
+ });
103
+ if (!result.success) {
104
+ return result;
105
+ }
106
+ const { stdout, stderr } = result.value;
107
+ const activationSuccessful = stdout.includes("successfully activated") ||
108
+ (!stdout.includes("License activation failed") && !stderr.includes("License activation failed"));
109
+ if (activationSuccessful) {
110
+ console.debug(`Successfully activated license for Unity ${projectInfo.editorVersion}`);
111
+ return ok(undefined);
112
+ }
113
+ return err(new UnityLicenseError(`Failed to activate license: ${stderr || stdout}`, {
114
+ projectInfo,
115
+ stderr,
116
+ stdout,
117
+ }));
143
118
  }
144
119
  static async returnLicense(projectInfo) {
145
- try {
146
- console.debug(`Returning Unity license for version ${projectInfo.editorVersion}`);
147
- const args = ["-quit", "-returnlicense"];
148
- const editorInfo = { version: projectInfo.editorVersion };
149
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
150
- reject: false,
151
- });
152
- const returnSuccessful = stdout.includes("license return succeeded") ||
153
- (!stdout.includes("Failed to return license") && !stderr.includes("Failed to return license"));
154
- if (returnSuccessful) {
155
- console.debug(`Successfully returned license for Unity ${projectInfo.editorVersion}`);
156
- return true;
157
- }
158
- else {
159
- console.error(`Failed to return license: ${stderr || stdout}`);
160
- return false;
161
- }
162
- }
163
- catch (error) {
164
- console.error("Error returning license:", error);
165
- return false;
166
- }
120
+ console.debug(`Returning Unity license for version ${projectInfo.editorVersion}`);
121
+ const args = ["-quit", "-returnlicense"];
122
+ const editorInfo = { version: projectInfo.editorVersion };
123
+ const result = await this.execUnityEditorCommand(editorInfo, args, {
124
+ reject: false,
125
+ });
126
+ if (!result.success) {
127
+ return result;
128
+ }
129
+ const { stdout, stderr } = result.value;
130
+ const returnSuccessful = stdout.includes("license return succeeded") ||
131
+ (!stdout.includes("Failed to return license") && !stderr.includes("Failed to return license"));
132
+ if (returnSuccessful) {
133
+ console.debug(`Successfully returned license for Unity ${projectInfo.editorVersion}`);
134
+ return ok(undefined);
135
+ }
136
+ return err(new UnityLicenseError(`Failed to return license: ${stderr || stdout}`, {
137
+ projectInfo,
138
+ stderr,
139
+ stdout,
140
+ }));
167
141
  }
168
142
  static async exportPackage(projectInfo, assetPaths, outputPath) {
169
- try {
170
- console.debug(`Exporting package from project`);
171
- const args = ["-projectPath", projectInfo.projectPath, "-exportPackage", ...assetPaths, outputPath, "-quit"];
172
- const editorInfo = { version: projectInfo.editorVersion };
173
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
174
- reject: false,
175
- });
176
- const exportSuccessful = !stdout.includes("Failed to export package") && !stderr.includes("Failed to export package");
177
- if (exportSuccessful) {
178
- console.debug(`Successfully exported package to ${outputPath}`);
179
- return true;
180
- }
181
- else {
182
- console.error(`Failed to export package: ${stderr || stdout}`);
183
- return false;
184
- }
185
- }
186
- catch (error) {
187
- console.error("Error exporting package:", error);
188
- return false;
189
- }
143
+ console.debug(`Exporting package from project`);
144
+ const args = ["-projectPath", projectInfo.projectPath, "-exportPackage", ...assetPaths, outputPath, "-quit"];
145
+ const editorInfo = { version: projectInfo.editorVersion };
146
+ const result = await this.execUnityEditorCommand(editorInfo, args, {
147
+ reject: false,
148
+ });
149
+ if (!result.success) {
150
+ return result;
151
+ }
152
+ const { stdout, stderr } = result.value;
153
+ const exportSuccessful = !stdout.includes("Failed to export package") && !stderr.includes("Failed to export package");
154
+ if (exportSuccessful) {
155
+ console.debug(`Successfully exported package to ${outputPath}`);
156
+ return ok(undefined);
157
+ }
158
+ return err(new UnityPackageError(`Failed to export package: ${stderr || stdout}`, {
159
+ projectInfo,
160
+ assetPaths,
161
+ outputPath,
162
+ stderr,
163
+ stdout,
164
+ }));
190
165
  }
191
166
  static async importPackage(projectInfo, packagePath) {
192
- try {
193
- console.debug(`Importing package ${packagePath} to project`);
194
- const args = ["-projectPath", projectInfo.projectPath, "-importPackage", packagePath, "-quit"];
195
- const editorInfo = { version: projectInfo.editorVersion };
196
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
197
- reject: false,
198
- });
199
- const importSuccessful = !stdout.includes("Failed to import package") && !stderr.includes("Failed to import package");
200
- if (importSuccessful) {
201
- console.debug(`Successfully imported package ${packagePath}`);
202
- return true;
203
- }
204
- else {
205
- console.error(`Failed to import package: ${stderr || stdout}`);
206
- return false;
207
- }
208
- }
209
- catch (error) {
210
- console.error("Error importing package:", error);
211
- return false;
212
- }
167
+ console.debug(`Importing package ${packagePath} to project`);
168
+ const args = ["-projectPath", projectInfo.projectPath, "-importPackage", packagePath, "-quit"];
169
+ const editorInfo = { version: projectInfo.editorVersion };
170
+ const result = await this.execUnityEditorCommand(editorInfo, args, {
171
+ reject: false,
172
+ });
173
+ if (!result.success) {
174
+ return result;
175
+ }
176
+ const { stdout, stderr } = result.value;
177
+ const importSuccessful = !stdout.includes("Failed to import package") && !stderr.includes("Failed to import package");
178
+ if (importSuccessful) {
179
+ console.debug(`Successfully imported package ${packagePath}`);
180
+ return ok(undefined);
181
+ }
182
+ return err(new UnityPackageError(`Failed to import package: ${stderr || stdout}`, {
183
+ projectInfo,
184
+ packagePath,
185
+ stderr,
186
+ stdout,
187
+ }));
213
188
  }
214
- static async createProject(projectInfo, quit = false, useHub = true) {
189
+ static async createProject(projectInfo, waitForExit = true) {
190
+ console.debug(`Creating new project at ${projectInfo.projectPath}`);
215
191
  try {
216
- console.debug(`Creating new project at ${projectInfo.projectPath}`);
217
192
  const parentDir = path.dirname(projectInfo.projectPath);
218
193
  await fs.ensureDir(parentDir);
219
194
  const args = ["-createProject", projectInfo.projectPath];
220
- if (useHub)
221
- args.push("-useHub", "-hubIPC");
222
- if (quit)
195
+ if (waitForExit) {
223
196
  args.push("-quit");
197
+ }
224
198
  const editorInfo = { version: projectInfo.editorVersion };
225
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
199
+ const result = await this.execUnityEditorCommand(editorInfo, args, {
226
200
  reject: false,
227
201
  });
202
+ if (!result.success) {
203
+ return result;
204
+ }
205
+ const { stdout, stderr } = result.value;
228
206
  const creationSuccessful = !stdout.includes("Failed to create project") && !stderr.includes("Failed to create project");
229
207
  if (creationSuccessful) {
230
208
  console.debug(`Successfully created project at ${projectInfo.projectPath}`);
231
- return true;
232
- }
233
- else {
234
- console.error(`Failed to create project: ${stderr || stdout}`);
235
- return false;
209
+ return ok(undefined);
236
210
  }
211
+ return err(new UnityProjectError(`Failed to create project: ${stderr || stdout}`, {
212
+ projectInfo,
213
+ stderr,
214
+ stdout,
215
+ }));
237
216
  }
238
217
  catch (error) {
239
218
  console.error("Error creating project:", error);
240
- return false;
241
- }
242
- }
243
- static async createProjectFromTemplate(projectInfo, templatePath, quit = false, useHub = true) {
244
- try {
245
- console.debug(`Creating new project from template at ${projectInfo.projectPath}`);
246
- const parentDir = path.dirname(projectInfo.projectPath);
247
- await fs.ensureDir(parentDir);
248
- const args = ["-createProject", projectInfo.projectPath, "-cloneFromTemplate", templatePath];
249
- if (quit)
250
- args.push("-quit");
251
- if (useHub)
252
- args.push("-useHub", "-hubIPC");
253
- const editorInfo = { version: projectInfo.editorVersion };
254
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, {
255
- reject: false,
256
- });
257
- const creationSuccessful = !stdout.includes("Failed to create project") && !stderr.includes("Failed to create project");
258
- if (creationSuccessful) {
259
- console.debug(`Successfully created project from template at ${projectInfo.projectPath}`);
260
- return true;
261
- }
262
- else {
263
- console.error(`Failed to create project from template: ${stderr || stdout}`);
264
- return false;
265
- }
266
- }
267
- catch (error) {
268
- console.error("Error creating project from template:", error);
269
- return false;
219
+ return err(new UnityProjectError(`Error creating project: ${String(error)}`, { projectInfo }));
270
220
  }
271
221
  }
272
222
  static async openProject(projectInfo, useHub = true, batchmode = false, waitForExit = true) {
273
- try {
274
- console.debug(`Opening project at ${projectInfo.projectPath}`);
275
- const args = ["-projectPath", projectInfo.projectPath];
276
- if (waitForExit)
277
- args.push("-quit");
278
- if (batchmode)
279
- args.push("-batchmode");
280
- if (useHub)
281
- args.push(...["-useHub", "-hubIPC"]);
282
- const editorInfo = { version: projectInfo.editorVersion };
283
- const options = { reject: false };
284
- const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, options);
285
- const openingSuccessful = !stdout.includes("Failed to open project") && !stderr.includes("Failed to open project");
286
- if (openingSuccessful) {
287
- console.debug(`Successfully opened project`);
288
- }
289
- else {
290
- console.error(`Failed to open project: ${stderr || stdout}`);
291
- }
292
- return openingSuccessful;
293
- }
294
- catch (error) {
295
- console.error("Error opening project:", error);
296
- return false;
297
- }
223
+ console.debug(`Opening project at ${projectInfo.projectPath}`);
224
+ const args = ["-projectPath", projectInfo.projectPath];
225
+ if (waitForExit) {
226
+ args.push("-quit");
227
+ }
228
+ if (batchmode) {
229
+ args.push("-batchmode");
230
+ }
231
+ if (useHub) {
232
+ args.push("-useHub", "-hubIPC");
233
+ }
234
+ const editorInfo = { version: projectInfo.editorVersion };
235
+ const result = await this.execUnityEditorCommand(editorInfo, args, { reject: false });
236
+ if (!result.success) {
237
+ return result;
238
+ }
239
+ const { stdout, stderr } = result.value;
240
+ const openingSuccessful = !stdout.includes("Failed to open project") && !stderr.includes("Failed to open project");
241
+ if (openingSuccessful) {
242
+ console.debug(`Successfully opened project`);
243
+ return ok(undefined);
244
+ }
245
+ return err(new UnityProjectError(`Failed to open project: ${stderr || stdout}`, {
246
+ projectInfo,
247
+ stderr,
248
+ stdout,
249
+ }));
298
250
  }
299
251
  }
300
252
  export default UnityEditor;
@@ -1,20 +1,22 @@
1
1
  import { EditorArchitecture, ModuleId, UnityInstallations } from "./types/unity.js";
2
- import { CommandOptions, CommandResult } from "./utils/commandExecutor.js";
3
- import { UnityHubInstallerEvent } from "./events/hubEventEmitter.ts";
2
+ import { CommandOptions, CommandOutput } from "./utils/commandExecutor.js";
3
+ import { UnityHubInstallerEvent } from "./events/hubEventEmitter.js";
4
+ import { Result, UnityHubNotFoundError, UnityCommandError, UnityInstallationError, UnityProjectError, InvalidArgumentError } from "./errors/index.js";
4
5
  declare class UnityHub {
6
+ private static CONFIG_PATHS;
5
7
  static getUnityHubPath(): string;
6
8
  static isUnityHubAvailable(): Promise<boolean>;
7
- static execUnityHubCommand(args: string[], options?: CommandOptions): Promise<CommandResult>;
8
- static getInstallPath(): Promise<string>;
9
- static setInstallPath(path: string): Promise<void>;
10
- static getUnityInstallations(filter?: string): Promise<UnityInstallations>;
11
- static addModule(editorVersion: string, modules: ModuleId[], childModules?: boolean): Promise<UnityHubInstallerEvent>;
12
- static addEditor(version: string, modules?: ModuleId[], architecture?: EditorArchitecture): Promise<UnityHubInstallerEvent>;
13
- static getProjects(): Promise<{
9
+ static execUnityHubCommand(args: string[], options?: CommandOptions): Promise<Result<CommandOutput, UnityHubNotFoundError | UnityCommandError>>;
10
+ static getInstallPath(): Promise<Result<string, UnityHubNotFoundError | UnityCommandError>>;
11
+ static setInstallPath(path: string): Promise<Result<void, UnityHubNotFoundError | UnityCommandError>>;
12
+ static getUnityInstallations(filter?: string): Promise<Result<UnityInstallations, InvalidArgumentError | UnityHubNotFoundError | UnityCommandError | UnityInstallationError>>;
13
+ static addModule(editorVersion: string, modules: ModuleId[], childModules?: boolean): Promise<Result<UnityHubInstallerEvent, InvalidArgumentError>>;
14
+ static addEditor(version: string, modules?: ModuleId[], architecture?: EditorArchitecture): Promise<Result<UnityHubInstallerEvent, UnityInstallationError>>;
15
+ static getProjects(): Promise<Result<{
14
16
  name: string;
15
17
  path: string;
16
18
  version: string;
17
- }[]>;
18
- static getDefaultProjectsDirectory(): Promise<string | null>;
19
+ }[], UnityProjectError>>;
20
+ static getDefaultProjectsDirectory(): Promise<Result<string | null, UnityProjectError>>;
19
21
  }
20
22
  export default UnityHub;