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