@notask/unity-cli-tools 1.0.4 → 1.0.6-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 +15 -0
- package/dist/cjs/unityEditor.js +6 -26
- package/dist/cjs/unityHub.js +8 -18
- package/dist/cjs/utils/security.js +27 -0
- package/dist/esm/types/unity.d.ts +1 -2
- package/dist/esm/unityEditor.d.ts +1 -1
- package/dist/esm/unityEditor.js +5 -25
- package/dist/esm/unityHub.d.ts +1 -3
- package/dist/esm/unityHub.js +9 -19
- package/dist/esm/utils/security.d.ts +1 -0
- package/dist/esm/utils/security.js +24 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.0.6-rc.1](https://github.com/NoTaskStudios/unity-cli-tools/compare/1.0.5...1.0.6-rc.1) (2025-04-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **Hub:** adjust in default params values ([ca12050](https://github.com/NoTaskStudios/unity-cli-tools/commit/ca120505433e4c6c01c54e1917de564a4883416b))
|
|
7
|
+
* **Hub:** Remove some class members ([78c37e2](https://github.com/NoTaskStudios/unity-cli-tools/commit/78c37e2b83197e6d8445bbdeeb23ff4c457eedd0))
|
|
8
|
+
|
|
9
|
+
## [1.0.5](https://github.com/NoTaskStudios/unity-cli-tools/compare/1.0.4...1.0.5) (2025-04-29)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **Editor:** Force hubIPC and usehub to add projects ([1da532a](https://github.com/NoTaskStudios/unity-cli-tools/commit/1da532a5db4cb9d1e7404861e570633b4661be99))
|
|
15
|
+
|
|
1
16
|
## [1.0.4](https://github.com/NoTaskStudios/unity-cli-tools/compare/1.0.3...1.0.4) (2025-04-29)
|
|
2
17
|
|
|
3
18
|
|
package/dist/cjs/unityEditor.js
CHANGED
|
@@ -8,6 +8,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
8
8
|
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
|
+
const security_js_1 = require("utils/security.js");
|
|
11
12
|
class UnityEditor {
|
|
12
13
|
static UNITY_PATHS = {
|
|
13
14
|
win32: {
|
|
@@ -51,7 +52,7 @@ class UnityEditor {
|
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
54
|
const editorArgs = [...args];
|
|
54
|
-
const redactedArgs = redactSensitiveArgs(editorArgs);
|
|
55
|
+
const redactedArgs = (0, security_js_1.redactSensitiveArgs)(editorArgs);
|
|
55
56
|
console.debug(`Executing Unity Editor command: ${unityPath} ${redactedArgs.join(" ")}`);
|
|
56
57
|
return await (0, commandExecutor_js_1.executeCommand)(unityPath, editorArgs, options);
|
|
57
58
|
}
|
|
@@ -239,7 +240,7 @@ class UnityEditor {
|
|
|
239
240
|
return false;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
|
-
static async openProject(projectInfo, batchmode = false, waitForExit = true) {
|
|
243
|
+
static async openProject(projectInfo, useHub = true, batchmode = false, waitForExit = true) {
|
|
243
244
|
try {
|
|
244
245
|
console.debug(`Opening project at ${projectInfo.projectPath}`);
|
|
245
246
|
const args = ["-projectPath", projectInfo.projectPath];
|
|
@@ -249,6 +250,9 @@ class UnityEditor {
|
|
|
249
250
|
if (batchmode) {
|
|
250
251
|
args.push("-batchmode");
|
|
251
252
|
}
|
|
253
|
+
if (useHub) {
|
|
254
|
+
args.push(...["-useHub", "-hubIPC"]);
|
|
255
|
+
}
|
|
252
256
|
const editorInfo = { version: projectInfo.editorVersion };
|
|
253
257
|
const options = { reject: false };
|
|
254
258
|
const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, options);
|
|
@@ -268,28 +272,4 @@ class UnityEditor {
|
|
|
268
272
|
}
|
|
269
273
|
}
|
|
270
274
|
}
|
|
271
|
-
function redactSensitiveArgs(argv, sensitiveKeys = ["password", "token", "secret"]) {
|
|
272
|
-
const redacted = [...argv];
|
|
273
|
-
for (let i = 0; i < redacted.length; i++) {
|
|
274
|
-
const arg = redacted[i];
|
|
275
|
-
if (arg.startsWith("--") || arg.startsWith("-")) {
|
|
276
|
-
const key = arg.replace(/^--?/, "");
|
|
277
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
278
|
-
if (i + 1 < redacted.length && !redacted[i + 1].startsWith("-")) {
|
|
279
|
-
redacted[i + 1] = "[REDACTED]";
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
const match = arg.match(/^--?([^=]+)=(.+)$/);
|
|
285
|
-
if (match) {
|
|
286
|
-
const key = match[1];
|
|
287
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
288
|
-
redacted[i] = `--${key}=[REDACTED]`;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return redacted;
|
|
294
|
-
}
|
|
295
275
|
exports.default = UnityEditor;
|
package/dist/cjs/unityHub.js
CHANGED
|
@@ -27,8 +27,6 @@ class UnityHub {
|
|
|
27
27
|
projectDir: path_1.default.join(os_1.default.homedir(), ".config", "UnityHub", "projectDir.json"),
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
|
-
static Modules = unity_js_1.UnityModules;
|
|
31
|
-
static Languages = unity_js_1.UnityEditorLanguages;
|
|
32
30
|
static platform = os_1.default.platform();
|
|
33
31
|
static hubPath = this.getUnityHubPath();
|
|
34
32
|
static getUnityHubPath() {
|
|
@@ -46,12 +44,7 @@ class UnityHub {
|
|
|
46
44
|
}
|
|
47
45
|
static async isUnityHubAvailable() {
|
|
48
46
|
try {
|
|
49
|
-
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
47
|
+
return !this.hubPath || !fs_extra_1.default.existsSync(this.hubPath);
|
|
55
48
|
}
|
|
56
49
|
catch (error) {
|
|
57
50
|
console.error("Error checking Unity Hub availability:", error);
|
|
@@ -124,20 +117,19 @@ class UnityHub {
|
|
|
124
117
|
throw new Error("No unity installations found.");
|
|
125
118
|
return installations;
|
|
126
119
|
}
|
|
127
|
-
static async addModule(editorVersion, modules, childModules =
|
|
120
|
+
static async addModule(editorVersion, modules, childModules = true) {
|
|
128
121
|
try {
|
|
129
122
|
console.debug(`Adding module ${modules} to Unity ${editorVersion}`);
|
|
130
123
|
const args = ["install-modules", "-v", editorVersion];
|
|
131
124
|
if (modules.length > 0) {
|
|
132
|
-
args.push("--module");
|
|
133
|
-
|
|
125
|
+
args.push(...["--module", modules.join(" ")]);
|
|
126
|
+
if (childModules) {
|
|
127
|
+
args.push("--child-modules");
|
|
128
|
+
}
|
|
134
129
|
}
|
|
135
130
|
else {
|
|
136
131
|
throw new Error("No module IDs provided.");
|
|
137
132
|
}
|
|
138
|
-
if (childModules) {
|
|
139
|
-
args.push("--child-modules");
|
|
140
|
-
}
|
|
141
133
|
const { stdout, stderr } = await this.execUnityHubCommand(args, {
|
|
142
134
|
reject: false,
|
|
143
135
|
});
|
|
@@ -155,9 +147,7 @@ class UnityHub {
|
|
|
155
147
|
try {
|
|
156
148
|
const data = await (0, unity_changeset_1.getUnityChangeset)(version);
|
|
157
149
|
const args = ["install", "-v", version];
|
|
158
|
-
|
|
159
|
-
args.push("--changeset", data.changeset);
|
|
160
|
-
}
|
|
150
|
+
args.push("--changeset", data.changeset);
|
|
161
151
|
if (modules.length > 0) {
|
|
162
152
|
args.push("--module");
|
|
163
153
|
args.push(modules.join(" "));
|
|
@@ -171,7 +161,7 @@ class UnityHub {
|
|
|
171
161
|
if (stderr) {
|
|
172
162
|
throw new Error(`Error installing Unity ${version}: ${stderr}`);
|
|
173
163
|
}
|
|
174
|
-
console.
|
|
164
|
+
console.debug(`Unity ${version}. ${stdout}`);
|
|
175
165
|
}
|
|
176
166
|
catch (error) {
|
|
177
167
|
console.error(error);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactSensitiveArgs = redactSensitiveArgs;
|
|
4
|
+
function redactSensitiveArgs(argv, sensitiveKeys = ["password", "token", "secret"]) {
|
|
5
|
+
const redacted = [...argv];
|
|
6
|
+
for (let i = 0; i < redacted.length; i++) {
|
|
7
|
+
const arg = redacted[i];
|
|
8
|
+
if (arg.startsWith("--") || arg.startsWith("-")) {
|
|
9
|
+
const key = arg.replace(/^--?/, "");
|
|
10
|
+
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
11
|
+
if (i + 1 < redacted.length && !redacted[i + 1].startsWith("-")) {
|
|
12
|
+
redacted[i + 1] = "[REDACTED]";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const match = arg.match(/^--?([^=]+)=(.+)$/);
|
|
18
|
+
if (match) {
|
|
19
|
+
const key = match[1];
|
|
20
|
+
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
21
|
+
redacted[i] = `--${key}=[REDACTED]`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return redacted;
|
|
27
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type UnityEditorInfo = Record<string, string>;
|
|
2
1
|
export interface UnityHubProject {
|
|
3
2
|
title: string;
|
|
4
3
|
lastModified: number;
|
|
@@ -49,11 +48,11 @@ export declare enum EditorArchitecture {
|
|
|
49
48
|
}
|
|
50
49
|
export type ModuleId = UnityModules | UnityEditorLanguages;
|
|
51
50
|
export type UnityInstallations = Record<string, string>;
|
|
51
|
+
export type UnityEditorInfo = Record<string, string>;
|
|
52
52
|
export interface ProjectInfo {
|
|
53
53
|
projectName: string;
|
|
54
54
|
projectPath: string;
|
|
55
55
|
editorVersion: string;
|
|
56
|
-
scenes?: string[];
|
|
57
56
|
}
|
|
58
57
|
export declare enum TestMode {
|
|
59
58
|
EditMode = "editmode",
|
|
@@ -14,6 +14,6 @@ declare class UnityEditor {
|
|
|
14
14
|
static exportPackage(projectInfo: ProjectInfo, assetPaths: string[], outputPath: string): Promise<boolean>;
|
|
15
15
|
static importPackage(projectInfo: ProjectInfo, packagePath: string): Promise<boolean>;
|
|
16
16
|
static createProject(projectInfo: ProjectInfo, waitForExit?: boolean): Promise<boolean>;
|
|
17
|
-
static openProject(projectInfo: ProjectInfo, batchmode?: boolean, waitForExit?: boolean): Promise<boolean>;
|
|
17
|
+
static openProject(projectInfo: ProjectInfo, useHub?: boolean, batchmode?: boolean, waitForExit?: boolean): Promise<boolean>;
|
|
18
18
|
}
|
|
19
19
|
export default UnityEditor;
|
package/dist/esm/unityEditor.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from "fs-extra";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { TestMode } from "./types/unity.js";
|
|
5
5
|
import { executeCommand } from "./utils/commandExecutor.js";
|
|
6
|
+
import { redactSensitiveArgs } from "utils/security.js";
|
|
6
7
|
class UnityEditor {
|
|
7
8
|
static UNITY_PATHS = {
|
|
8
9
|
win32: {
|
|
@@ -234,7 +235,7 @@ class UnityEditor {
|
|
|
234
235
|
return false;
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
|
-
static async openProject(projectInfo, batchmode = false, waitForExit = true) {
|
|
238
|
+
static async openProject(projectInfo, useHub = true, batchmode = false, waitForExit = true) {
|
|
238
239
|
try {
|
|
239
240
|
console.debug(`Opening project at ${projectInfo.projectPath}`);
|
|
240
241
|
const args = ["-projectPath", projectInfo.projectPath];
|
|
@@ -244,6 +245,9 @@ class UnityEditor {
|
|
|
244
245
|
if (batchmode) {
|
|
245
246
|
args.push("-batchmode");
|
|
246
247
|
}
|
|
248
|
+
if (useHub) {
|
|
249
|
+
args.push(...["-useHub", "-hubIPC"]);
|
|
250
|
+
}
|
|
247
251
|
const editorInfo = { version: projectInfo.editorVersion };
|
|
248
252
|
const options = { reject: false };
|
|
249
253
|
const { stdout, stderr } = await this.execUnityEditorCommand(editorInfo, args, options);
|
|
@@ -263,28 +267,4 @@ class UnityEditor {
|
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
}
|
|
266
|
-
function redactSensitiveArgs(argv, sensitiveKeys = ["password", "token", "secret"]) {
|
|
267
|
-
const redacted = [...argv];
|
|
268
|
-
for (let i = 0; i < redacted.length; i++) {
|
|
269
|
-
const arg = redacted[i];
|
|
270
|
-
if (arg.startsWith("--") || arg.startsWith("-")) {
|
|
271
|
-
const key = arg.replace(/^--?/, "");
|
|
272
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
273
|
-
if (i + 1 < redacted.length && !redacted[i + 1].startsWith("-")) {
|
|
274
|
-
redacted[i + 1] = "[REDACTED]";
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
const match = arg.match(/^--?([^=]+)=(.+)$/);
|
|
280
|
-
if (match) {
|
|
281
|
-
const key = match[1];
|
|
282
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
283
|
-
redacted[i] = `--${key}=[REDACTED]`;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return redacted;
|
|
289
|
-
}
|
|
290
270
|
export default UnityEditor;
|
package/dist/esm/unityHub.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { EditorArchitecture, ModuleId, UnityInstallations
|
|
1
|
+
import { EditorArchitecture, ModuleId, UnityInstallations } from "./types/unity.js";
|
|
2
2
|
import { CommandOptions, CommandResult } from "./utils/commandExecutor.js";
|
|
3
3
|
declare class UnityHub {
|
|
4
4
|
private static CONFIG_PATHS;
|
|
5
|
-
static readonly Modules: typeof UnityModules;
|
|
6
|
-
static readonly Languages: typeof UnityEditorLanguages;
|
|
7
5
|
static getUnityHubPath(): string;
|
|
8
6
|
static isUnityHubAvailable(): Promise<boolean>;
|
|
9
7
|
static execUnityHubCommand(args: string[], options?: CommandOptions): Promise<CommandResult>;
|
package/dist/esm/unityHub.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { EditorArchitecture,
|
|
4
|
+
import { EditorArchitecture, } from "./types/unity.js";
|
|
5
5
|
import { executeCommand } from "./utils/commandExecutor.js";
|
|
6
6
|
import { getUnityChangeset } from "unity-changeset";
|
|
7
7
|
class UnityHub {
|
|
@@ -22,8 +22,6 @@ class UnityHub {
|
|
|
22
22
|
projectDir: path.join(os.homedir(), ".config", "UnityHub", "projectDir.json"),
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
|
-
static Modules = UnityModules;
|
|
26
|
-
static Languages = UnityEditorLanguages;
|
|
27
25
|
static platform = os.platform();
|
|
28
26
|
static hubPath = this.getUnityHubPath();
|
|
29
27
|
static getUnityHubPath() {
|
|
@@ -41,12 +39,7 @@ class UnityHub {
|
|
|
41
39
|
}
|
|
42
40
|
static async isUnityHubAvailable() {
|
|
43
41
|
try {
|
|
44
|
-
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
42
|
+
return !this.hubPath || !fs.existsSync(this.hubPath);
|
|
50
43
|
}
|
|
51
44
|
catch (error) {
|
|
52
45
|
console.error("Error checking Unity Hub availability:", error);
|
|
@@ -119,20 +112,19 @@ class UnityHub {
|
|
|
119
112
|
throw new Error("No unity installations found.");
|
|
120
113
|
return installations;
|
|
121
114
|
}
|
|
122
|
-
static async addModule(editorVersion, modules, childModules =
|
|
115
|
+
static async addModule(editorVersion, modules, childModules = true) {
|
|
123
116
|
try {
|
|
124
117
|
console.debug(`Adding module ${modules} to Unity ${editorVersion}`);
|
|
125
118
|
const args = ["install-modules", "-v", editorVersion];
|
|
126
119
|
if (modules.length > 0) {
|
|
127
|
-
args.push("--module");
|
|
128
|
-
|
|
120
|
+
args.push(...["--module", modules.join(" ")]);
|
|
121
|
+
if (childModules) {
|
|
122
|
+
args.push("--child-modules");
|
|
123
|
+
}
|
|
129
124
|
}
|
|
130
125
|
else {
|
|
131
126
|
throw new Error("No module IDs provided.");
|
|
132
127
|
}
|
|
133
|
-
if (childModules) {
|
|
134
|
-
args.push("--child-modules");
|
|
135
|
-
}
|
|
136
128
|
const { stdout, stderr } = await this.execUnityHubCommand(args, {
|
|
137
129
|
reject: false,
|
|
138
130
|
});
|
|
@@ -150,9 +142,7 @@ class UnityHub {
|
|
|
150
142
|
try {
|
|
151
143
|
const data = await getUnityChangeset(version);
|
|
152
144
|
const args = ["install", "-v", version];
|
|
153
|
-
|
|
154
|
-
args.push("--changeset", data.changeset);
|
|
155
|
-
}
|
|
145
|
+
args.push("--changeset", data.changeset);
|
|
156
146
|
if (modules.length > 0) {
|
|
157
147
|
args.push("--module");
|
|
158
148
|
args.push(modules.join(" "));
|
|
@@ -166,7 +156,7 @@ class UnityHub {
|
|
|
166
156
|
if (stderr) {
|
|
167
157
|
throw new Error(`Error installing Unity ${version}: ${stderr}`);
|
|
168
158
|
}
|
|
169
|
-
console.
|
|
159
|
+
console.debug(`Unity ${version}. ${stdout}`);
|
|
170
160
|
}
|
|
171
161
|
catch (error) {
|
|
172
162
|
console.error(error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function redactSensitiveArgs(argv, sensitiveKeys = ["password", "token", "secret"]) {
|
|
2
|
+
const redacted = [...argv];
|
|
3
|
+
for (let i = 0; i < redacted.length; i++) {
|
|
4
|
+
const arg = redacted[i];
|
|
5
|
+
if (arg.startsWith("--") || arg.startsWith("-")) {
|
|
6
|
+
const key = arg.replace(/^--?/, "");
|
|
7
|
+
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
8
|
+
if (i + 1 < redacted.length && !redacted[i + 1].startsWith("-")) {
|
|
9
|
+
redacted[i + 1] = "[REDACTED]";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const match = arg.match(/^--?([^=]+)=(.+)$/);
|
|
15
|
+
if (match) {
|
|
16
|
+
const key = match[1];
|
|
17
|
+
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
18
|
+
redacted[i] = `--${key}=[REDACTED]`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return redacted;
|
|
24
|
+
}
|