@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
@@ -5,26 +5,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_extra_1 = __importDefault(require("fs-extra"));
7
7
  const os_1 = __importDefault(require("os"));
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 unity_changeset_1 = require("unity-changeset");
11
- const hubEventEmitter_ts_1 = require("./events/hubEventEmitter.js");
12
- const unityConfig_ts_1 = require("./configs/unityConfig.js");
12
+ const hubEventEmitter_js_1 = require("./events/hubEventEmitter.js");
13
+ const index_js_1 = require("./errors/index.js");
13
14
  class UnityHub {
14
- static unityConfig = unityConfig_ts_1.UnityConfig.getPlatformConfig();
15
+ static CONFIG_PATHS = {
16
+ win32: {
17
+ hub: "C:\\Program Files\\Unity Hub\\Unity Hub.exe",
18
+ projects: path_1.default.join(os_1.default.homedir(), "AppData", "Roaming", "UnityHub", "projects-v1.json"),
19
+ projectDir: path_1.default.join(os_1.default.homedir(), "AppData", "Roaming", "UnityHub", "projectDir.json"),
20
+ },
21
+ darwin: {
22
+ hub: "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub",
23
+ projects: path_1.default.join(os_1.default.homedir(), "Library", "Application Support", "UnityHub", "projects-v1.json"),
24
+ projectDir: path_1.default.join(os_1.default.homedir(), "Library", "Application Support", "UnityHub", "projectDir.json"),
25
+ },
26
+ linux: {
27
+ hub: "/opt/UnityHub/UnityHub",
28
+ projects: path_1.default.join(os_1.default.homedir(), ".config", "UnityHub", "projects-v1.json"),
29
+ projectDir: path_1.default.join(os_1.default.homedir(), ".config", "UnityHub", "projectDir.json"),
30
+ },
31
+ };
32
+ static platform = os_1.default.platform();
33
+ static hubPath = this.getUnityHubPath();
15
34
  static getUnityHubPath() {
16
- return this.unityConfig.hub.hubDir;
35
+ const envPath = process.env.UNITY_HUB_PATH ?? "";
36
+ if (envPath && fs_extra_1.default.existsSync(envPath)) {
37
+ return envPath;
38
+ }
39
+ return UnityHub.CONFIG_PATHS[this.platform].hub || "";
17
40
  }
18
41
  static getProjectsPath() {
19
- return this.unityConfig.hub.projects;
42
+ return UnityHub.CONFIG_PATHS[this.platform].projects || "";
20
43
  }
21
44
  static getProjectDirPath() {
22
- return this.unityConfig.hub.projectDir;
45
+ return UnityHub.CONFIG_PATHS[this.platform].projectDir || "";
23
46
  }
24
47
  static async isUnityHubAvailable() {
25
48
  try {
26
- const hubPath = this.getUnityHubPath();
27
- return !!hubPath && fs_extra_1.default.existsSync(hubPath);
49
+ return !!this.hubPath && fs_extra_1.default.existsSync(this.hubPath);
28
50
  }
29
51
  catch (error) {
30
52
  console.error("Error checking Unity Hub availability:", error);
@@ -35,122 +57,124 @@ class UnityHub {
35
57
  const isAvailable = await UnityHub.isUnityHubAvailable();
36
58
  if (!isAvailable) {
37
59
  console.error("Unity Hub is not available.");
38
- return {
39
- success: false,
40
- stdout: "",
41
- stderr: "Unity Hub is not available.",
42
- exitCode: -1,
43
- };
44
- }
45
- try {
46
- const hubArgs = [this.unityConfig.platform !== "linux" ? "--" : "", "--headless", ...args].filter(Boolean);
47
- console.debug(`Executing Unity Hub command: ${this.getUnityHubPath()} ${hubArgs.join(" ")}`);
48
- return await (0, commandExecutor_js_1.executeCommand)(this.unityConfig.hub.hubDir, hubArgs, options);
49
- }
50
- catch (error) {
51
- console.error("Error executing Unity Hub command:", error);
52
- return {
53
- success: false,
54
- stdout: "",
55
- stderr: String(error),
56
- exitCode: -1,
57
- };
60
+ return (0, index_js_1.err)(new index_js_1.UnityHubNotFoundError("Unity Hub is not available", { hubPath: this.hubPath }));
58
61
  }
62
+ const hubArgs = [this.platform !== "linux" ? "--" : "", "--headless", ...args].filter(Boolean);
63
+ console.debug(`Executing Unity Hub command: ${this.hubPath} ${hubArgs.join(" ")}`);
64
+ return await (0, commandExecutor_js_1.executeCommand)(this.hubPath, hubArgs, options);
59
65
  }
60
66
  static async getInstallPath() {
61
- const { stdout, stderr } = await this.execUnityHubCommand(["install-path", "-g"], {
67
+ const result = await this.execUnityHubCommand(["install-path", "-g"], {
62
68
  reject: false,
63
69
  });
64
- if (stderr) {
65
- throw new Error(`Error getting install path: ${stderr}`);
70
+ if (!result.success) {
71
+ return result;
66
72
  }
67
- return stdout;
73
+ if (result.value.stderr) {
74
+ return (0, index_js_1.err)(new index_js_1.UnityCommandError(`Error getting install path: ${result.value.stderr}`, result.value.stdout, result.value.stderr, result.value.exitCode));
75
+ }
76
+ return (0, index_js_1.ok)(result.value.stdout.trim());
68
77
  }
69
78
  static async setInstallPath(path) {
70
- const { stdout, stderr } = await this.execUnityHubCommand(["install-path", "-s", path], {
79
+ const result = await this.execUnityHubCommand(["install-path", "-s", path], {
71
80
  reject: false,
72
81
  });
73
- if (stderr) {
74
- throw new Error(`Error setting install path: ${stderr}`);
82
+ if (!result.success) {
83
+ return result;
75
84
  }
76
- console.debug(`Install path set to: ${stdout}`);
85
+ if (result.value.stderr) {
86
+ return (0, index_js_1.err)(new index_js_1.UnityCommandError(`Error setting install path: ${result.value.stderr}`, result.value.stdout, result.value.stderr, result.value.exitCode));
87
+ }
88
+ console.debug(`Install path set to: ${result.value.stdout}`);
89
+ return (0, index_js_1.ok)(undefined);
77
90
  }
78
91
  static async getUnityInstallations(filter = "i") {
79
92
  if (!["i", "a", "r"].includes(filter)) {
80
- throw new Error(`Invalid filter "${filter}". Use "i" for installed, "a" for all, or "r" for available releases.`);
93
+ return (0, index_js_1.err)(new index_js_1.InvalidArgumentError(`Invalid filter "${filter}". Use "i" for installed, "a" for all, or "r" for available releases.`, { filter, validFilters: ["i", "a", "r"] }));
81
94
  }
82
- const { stdout, stderr } = await this.execUnityHubCommand(["editors", `-${filter}`], {
95
+ const result = await this.execUnityHubCommand(["editors", `-${filter}`], {
83
96
  reject: false,
84
97
  });
98
+ if (!result.success) {
99
+ return result;
100
+ }
101
+ const { stdout, stderr } = result.value;
85
102
  const isSuccess = stdout.includes(", installed at");
86
- if (stderr)
87
- throw new Error(`Get installations command warning/error: ${stderr}`);
88
- if (!isSuccess)
89
- throw new Error(`Consider install a Unity version using Unity Hub.`);
103
+ if (stderr) {
104
+ return (0, index_js_1.err)(new index_js_1.UnityCommandError(`Get installations command warning/error: ${stderr}`, stdout, stderr, result.value.exitCode));
105
+ }
106
+ if (!isSuccess) {
107
+ return (0, index_js_1.err)(new index_js_1.UnityInstallationError("No Unity installations found. Consider installing a Unity version using Unity Hub.", {
108
+ filter,
109
+ }));
110
+ }
90
111
  const lines = stdout.split(/\r\n|\n/);
91
112
  const installations = {};
92
113
  lines.forEach((line) => {
93
114
  const [version, unityPath] = line.split(", installed at").map((entry) => entry.trim());
94
- installations[version] = unityPath;
115
+ if (version && unityPath) {
116
+ installations[version] = unityPath;
117
+ }
95
118
  });
96
- if (Object.keys(installations).length <= 0)
97
- throw new Error("No unity installations found.");
98
- return installations;
119
+ if (Object.keys(installations).length <= 0) {
120
+ return (0, index_js_1.err)(new index_js_1.UnityInstallationError("No Unity installations found.", { filter }));
121
+ }
122
+ return (0, index_js_1.ok)(installations);
99
123
  }
100
124
  static async addModule(editorVersion, modules, childModules = true) {
101
- try {
102
- console.debug(`Adding module ${modules} to Unity ${editorVersion}`);
103
- const args = ["install-modules", "-v", editorVersion];
104
- if (modules.length > 0) {
105
- args.push(...["--module", modules.join(" ")]);
106
- if (childModules) {
107
- args.push("--child-modules");
108
- }
109
- }
110
- else {
111
- throw new Error("No module IDs provided.");
112
- }
113
- const installerEmitter = new hubEventEmitter_ts_1.UnityHubInstallerEvent();
114
- this.execUnityHubCommand(args, {
115
- reject: false,
116
- onStdout: (data) => installerEmitter.Progress(data),
117
- }).catch((error) => {
118
- console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
119
- });
120
- return installerEmitter;
125
+ if (modules.length === 0) {
126
+ return (0, index_js_1.err)(new index_js_1.InvalidArgumentError("No module IDs provided.", { editorVersion, modules }));
121
127
  }
122
- catch (error) {
123
- console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
124
- throw error;
128
+ console.debug(`Adding module ${modules} to Unity ${editorVersion}`);
129
+ const args = ["install-modules", "-v", editorVersion, "--module", modules.join(" ")];
130
+ if (childModules) {
131
+ args.push("--child-modules");
125
132
  }
133
+ const installerEmitter = new hubEventEmitter_js_1.UnityHubInstallerEvent();
134
+ this.execUnityHubCommand(args, {
135
+ reject: false,
136
+ onStdout: (data) => installerEmitter.Progress(data),
137
+ })
138
+ .then((result) => {
139
+ if (!result.success) {
140
+ console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, result.error);
141
+ }
142
+ })
143
+ .catch((error) => {
144
+ console.error(`Error adding module ${modules} to Unity ${editorVersion}:`, error);
145
+ });
146
+ return (0, index_js_1.ok)(installerEmitter);
126
147
  }
127
148
  static async addEditor(version, modules = [], architecture) {
128
149
  try {
129
150
  const data = await (0, unity_changeset_1.getUnityChangeset)(version);
130
- const args = ["install", "-v", version];
131
- args.push("--changeset", data.changeset);
151
+ const args = ["install", "-v", version, "--changeset", data.changeset];
132
152
  if (modules.length > 0) {
133
- args.push("--module");
134
- args.push(modules.join(" "));
153
+ args.push("--module", modules.join(" "));
135
154
  }
136
155
  if (!architecture) {
137
156
  const arch = os_1.default.arch() || process.arch;
138
- const defaultArchitecture = arch === "arm64" || arch === "arm" ? unity_js_1.EditorArchitecture.arm64 : unity_js_1.EditorArchitecture.x86_64;
139
- architecture = defaultArchitecture;
157
+ architecture = arch === "arm64" || arch === "arm" ? unity_js_1.EditorArchitecture.arm64 : unity_js_1.EditorArchitecture.x86_64;
140
158
  }
141
159
  args.push("--architecture", architecture);
142
- const installerEmitter = new hubEventEmitter_ts_1.UnityHubInstallerEvent();
160
+ const installerEmitter = new hubEventEmitter_js_1.UnityHubInstallerEvent();
143
161
  this.execUnityHubCommand(args, {
144
162
  reject: false,
145
163
  onStdout: (data) => installerEmitter.Progress(data),
146
- }).catch((error) => {
164
+ })
165
+ .then((result) => {
166
+ if (!result.success) {
167
+ console.error(`Error installing Unity ${version}:`, result.error);
168
+ }
169
+ })
170
+ .catch((error) => {
147
171
  console.error(`Error installing Unity ${version}:`, error);
148
172
  });
149
- return installerEmitter;
173
+ return (0, index_js_1.ok)(installerEmitter);
150
174
  }
151
175
  catch (error) {
152
176
  console.error(error);
153
- throw error;
177
+ return (0, index_js_1.err)(new index_js_1.UnityInstallationError(`Failed to install Unity ${version}: ${String(error)}`, { version, modules, architecture }));
154
178
  }
155
179
  }
156
180
  static async getProjects() {
@@ -158,19 +182,20 @@ class UnityHub {
158
182
  const projectsPath = this.getProjectsPath();
159
183
  if (!projectsPath || !fs_extra_1.default.existsSync(projectsPath)) {
160
184
  console.debug(`Projects file not found at: ${projectsPath}`);
161
- return [];
185
+ return (0, index_js_1.err)(new index_js_1.UnityProjectError(`Projects file not found at: ${projectsPath}`, { projectsPath }));
162
186
  }
163
187
  const projectsData = await fs_extra_1.default.readJson(projectsPath);
164
188
  const projects = Object.values(projectsData.data);
165
- return projects.map((project) => ({
189
+ const mappedProjects = projects.map((project) => ({
166
190
  name: project.title,
167
191
  path: project.path,
168
192
  version: project.version,
169
193
  }));
194
+ return (0, index_js_1.ok)(mappedProjects);
170
195
  }
171
196
  catch (error) {
172
197
  console.error("Error getting recent projects:", error);
173
- return [];
198
+ return (0, index_js_1.err)(new index_js_1.UnityProjectError(`Failed to get projects: ${String(error)}`));
174
199
  }
175
200
  }
176
201
  static async getDefaultProjectsDirectory() {
@@ -178,14 +203,14 @@ class UnityHub {
178
203
  const projectDirPath = this.getProjectDirPath();
179
204
  if (!projectDirPath || !fs_extra_1.default.existsSync(projectDirPath)) {
180
205
  console.debug(`Project directory file not found at: ${projectDirPath}`);
181
- return null;
206
+ return (0, index_js_1.ok)(null);
182
207
  }
183
208
  const projectDirData = await fs_extra_1.default.readJson(projectDirPath);
184
- return projectDirData.directoryPath ?? null;
209
+ return (0, index_js_1.ok)(projectDirData.directoryPath ?? null);
185
210
  }
186
211
  catch (error) {
187
212
  console.error("Error getting default project directory:", error);
188
- return null;
213
+ return (0, index_js_1.err)(new index_js_1.UnityProjectError(`Failed to get default project directory: ${String(error)}`));
189
214
  }
190
215
  }
191
216
  }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeCommand = executeCommand;
4
4
  const execa_1 = require("execa");
5
+ const index_js_1 = require("../errors/index.js");
6
+ const index_js_2 = require("../errors/index.js");
5
7
  async function executeCommand(executable, args, options = {}) {
6
8
  try {
7
9
  const streamOutput = options.onStdout || options.onStderr;
@@ -40,19 +42,16 @@ async function executeCommand(executable, args, options = {}) {
40
42
  }
41
43
  }
42
44
  const { stdout, stderr, exitCode } = await subprocess;
43
- return {
44
- success: true,
45
+ return (0, index_js_1.ok)({
45
46
  stdout,
46
47
  stderr,
47
48
  exitCode,
48
- };
49
+ });
49
50
  }
50
51
  catch (error) {
51
- return {
52
- success: false,
53
- stdout: error.stdout ?? "",
54
- stderr: error.stderr ?? String(error),
55
- exitCode: error.exitCode,
56
- };
52
+ const stdout = error.stdout ?? "";
53
+ const stderr = error.stderr ?? String(error);
54
+ const exitCode = error.exitCode;
55
+ return (0, index_js_1.err)(new index_js_2.UnityCommandError(`Command execution failed: ${executable} ${args.join(" ")}`, stdout, stderr, exitCode, { executable, args }));
57
56
  }
58
57
  }
@@ -0,0 +1,21 @@
1
+ import { UnityError } from "./UnityError.js";
2
+ export interface Success<T> {
3
+ readonly success: true;
4
+ readonly value: T;
5
+ }
6
+ export interface Failure<E extends UnityError> {
7
+ readonly success: false;
8
+ readonly error: E;
9
+ }
10
+ export type Result<T, E extends UnityError = UnityError> = Success<T> | Failure<E>;
11
+ export declare function ok<T>(value: T): Success<T>;
12
+ export declare function err<E extends UnityError>(error: E): Failure<E>;
13
+ export declare function isOk<T, E extends UnityError>(result: Result<T, E>): result is Success<T>;
14
+ export declare function isErr<T, E extends UnityError>(result: Result<T, E>): result is Failure<E>;
15
+ export declare function unwrap<T, E extends UnityError>(result: Result<T, E>): T;
16
+ export declare function unwrapOr<T, E extends UnityError>(result: Result<T, E>, defaultValue: T): T;
17
+ export declare function map<T, U, E extends UnityError>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
18
+ export declare function mapErr<T, E extends UnityError, F extends UnityError>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
19
+ export declare function andThen<T, U, E extends UnityError>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
20
+ export declare function firstOk<T, E extends UnityError>(results: Result<T, E>[]): Result<T, E>;
21
+ export declare function combine<T, E extends UnityError>(results: Result<T, E>[]): Result<T[], E>;
@@ -0,0 +1,63 @@
1
+ export function ok(value) {
2
+ return { success: true, value };
3
+ }
4
+ export function err(error) {
5
+ return { success: false, error };
6
+ }
7
+ export function isOk(result) {
8
+ return result.success === true;
9
+ }
10
+ export function isErr(result) {
11
+ return result.success === false;
12
+ }
13
+ export function unwrap(result) {
14
+ if (isOk(result)) {
15
+ return result.value;
16
+ }
17
+ throw result.error;
18
+ }
19
+ export function unwrapOr(result, defaultValue) {
20
+ if (isOk(result)) {
21
+ return result.value;
22
+ }
23
+ return defaultValue;
24
+ }
25
+ export function map(result, fn) {
26
+ if (isOk(result)) {
27
+ return ok(fn(result.value));
28
+ }
29
+ return result;
30
+ }
31
+ export function mapErr(result, fn) {
32
+ if (isErr(result)) {
33
+ return err(fn(result.error));
34
+ }
35
+ return result;
36
+ }
37
+ export function andThen(result, fn) {
38
+ if (isOk(result)) {
39
+ return fn(result.value);
40
+ }
41
+ return result;
42
+ }
43
+ export function firstOk(results) {
44
+ if (results.length === 0) {
45
+ throw new Error("Cannot call firstOk on empty array");
46
+ }
47
+ for (const result of results) {
48
+ if (isOk(result)) {
49
+ return result;
50
+ }
51
+ }
52
+ return results[results.length - 1];
53
+ }
54
+ export function combine(results) {
55
+ const values = [];
56
+ for (const result of results) {
57
+ if (isErr(result)) {
58
+ return result;
59
+ }
60
+ values.push(result.value);
61
+ }
62
+ return ok(values);
63
+ }
@@ -0,0 +1,36 @@
1
+ export declare abstract class UnityError extends Error {
2
+ readonly code: string;
3
+ readonly context?: Record<string, unknown>;
4
+ constructor(message: string, code: string, context?: Record<string, unknown>);
5
+ }
6
+ export declare class UnityHubNotFoundError extends UnityError {
7
+ constructor(message?: string, context?: Record<string, unknown>);
8
+ }
9
+ export declare class UnityEditorNotFoundError extends UnityError {
10
+ constructor(version: string, path?: string);
11
+ }
12
+ export declare class UnityCommandError extends UnityError {
13
+ readonly stdout: string;
14
+ readonly stderr: string;
15
+ readonly exitCode?: number;
16
+ constructor(message: string, stdout?: string, stderr?: string, exitCode?: number, context?: Record<string, unknown>);
17
+ }
18
+ export declare class UnityInstallationError extends UnityError {
19
+ constructor(message: string, context?: Record<string, unknown>);
20
+ }
21
+ export declare class UnityProjectError extends UnityError {
22
+ constructor(message: string, context?: Record<string, unknown>);
23
+ }
24
+ export declare class UnityLicenseError extends UnityError {
25
+ constructor(message: string, context?: Record<string, unknown>);
26
+ }
27
+ export declare class UnityPackageError extends UnityError {
28
+ constructor(message: string, context?: Record<string, unknown>);
29
+ }
30
+ export declare class UnityTestError extends UnityError {
31
+ readonly testOutput: string;
32
+ constructor(message: string, testOutput?: string, context?: Record<string, unknown>);
33
+ }
34
+ export declare class InvalidArgumentError extends UnityError {
35
+ constructor(message: string, context?: Record<string, unknown>);
36
+ }
@@ -0,0 +1,64 @@
1
+ export class UnityError extends Error {
2
+ code;
3
+ context;
4
+ constructor(message, code, context) {
5
+ super(message);
6
+ this.name = this.constructor.name;
7
+ this.code = code;
8
+ this.context = context;
9
+ Error.captureStackTrace(this, this.constructor);
10
+ }
11
+ }
12
+ export class UnityHubNotFoundError extends UnityError {
13
+ constructor(message = "Unity Hub is not available", context) {
14
+ super(message, "UNITY_HUB_NOT_FOUND", context);
15
+ }
16
+ }
17
+ export class UnityEditorNotFoundError extends UnityError {
18
+ constructor(version, path) {
19
+ super(`Unity Editor version ${version} not found${path ? ` at path: ${path}` : ""}`, "UNITY_EDITOR_NOT_FOUND", { version, path });
20
+ }
21
+ }
22
+ export class UnityCommandError extends UnityError {
23
+ stdout;
24
+ stderr;
25
+ exitCode;
26
+ constructor(message, stdout = "", stderr = "", exitCode, context) {
27
+ super(message, "UNITY_COMMAND_ERROR", context);
28
+ this.stdout = stdout;
29
+ this.stderr = stderr;
30
+ this.exitCode = exitCode;
31
+ }
32
+ }
33
+ export class UnityInstallationError extends UnityError {
34
+ constructor(message, context) {
35
+ super(message, "UNITY_INSTALLATION_ERROR", context);
36
+ }
37
+ }
38
+ export class UnityProjectError extends UnityError {
39
+ constructor(message, context) {
40
+ super(message, "UNITY_PROJECT_ERROR", context);
41
+ }
42
+ }
43
+ export class UnityLicenseError extends UnityError {
44
+ constructor(message, context) {
45
+ super(message, "UNITY_LICENSE_ERROR", context);
46
+ }
47
+ }
48
+ export class UnityPackageError extends UnityError {
49
+ constructor(message, context) {
50
+ super(message, "UNITY_PACKAGE_ERROR", context);
51
+ }
52
+ }
53
+ export class UnityTestError extends UnityError {
54
+ testOutput;
55
+ constructor(message, testOutput = "", context) {
56
+ super(message, "UNITY_TEST_ERROR", context);
57
+ this.testOutput = testOutput;
58
+ }
59
+ }
60
+ export class InvalidArgumentError extends UnityError {
61
+ constructor(message, context) {
62
+ super(message, "INVALID_ARGUMENT", context);
63
+ }
64
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Result.js";
2
+ export * from "./UnityError.js";
@@ -0,0 +1,2 @@
1
+ export * from "./Result.js";
2
+ export * from "./UnityError.js";
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from "events";
2
- import { InstallerEventType, InstallerEvent } from "../types/unity.ts";
2
+ import { InstallerEventType, InstallerEvent } from "../types/unity.js";
3
3
  export interface InstallerEmitter extends EventEmitter {
4
4
  on(event: InstallerEventType.Progress, listener: (info: InstallerEvent[]) => void): this;
5
5
  on(event: InstallerEventType.Error, listener: (error: Error) => void): this;
@@ -1,6 +1,20 @@
1
- import { InstallerEvent } from "../types/unity.ts";
1
+ import { InstallerEvent } from "../types/unity.js";
2
+ import { ParserConfig, ParseResult, Pattern } from "./patterns/index.js";
2
3
  export declare class UnityHubEventParser {
3
- private static errorPatterns;
4
+ private static patternRegistry;
5
+ private static statusNormalizer;
6
+ private static config;
7
+ private static initialize;
4
8
  static parseUnityHubEvent(event: string): InstallerEvent[];
5
- private static checkForErrors;
9
+ static parseWithDetails(event: string): ParseResult;
10
+ static setLocale(locale: string): void;
11
+ static getLocale(): string;
12
+ static registerCustomPattern(pattern: Pattern): void;
13
+ static addStatusNormalization(statusText: string, status: any, locale?: string): void;
14
+ static getUnknownStatuses(): string[];
15
+ static clearUnknownStatuses(): void;
16
+ static configure(config: Partial<ParserConfig>): void;
17
+ static getConfig(): Readonly<ParserConfig>;
18
+ static reset(): void;
19
+ static getPatternNames(): string[];
6
20
  }