@notask/unity-cli-tools 1.0.5 → 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 +8 -0
- package/dist/cjs/unityEditor.js +2 -25
- 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.js +1 -24
- 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,11 @@
|
|
|
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
|
+
|
|
1
9
|
## [1.0.5](https://github.com/NoTaskStudios/unity-cli-tools/compare/1.0.4...1.0.5) (2025-04-29)
|
|
2
10
|
|
|
3
11
|
|
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
|
}
|
|
@@ -271,28 +272,4 @@ class UnityEditor {
|
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
|
-
function redactSensitiveArgs(argv, sensitiveKeys = ["password", "token", "secret"]) {
|
|
275
|
-
const redacted = [...argv];
|
|
276
|
-
for (let i = 0; i < redacted.length; i++) {
|
|
277
|
-
const arg = redacted[i];
|
|
278
|
-
if (arg.startsWith("--") || arg.startsWith("-")) {
|
|
279
|
-
const key = arg.replace(/^--?/, "");
|
|
280
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
281
|
-
if (i + 1 < redacted.length && !redacted[i + 1].startsWith("-")) {
|
|
282
|
-
redacted[i + 1] = "[REDACTED]";
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
const match = arg.match(/^--?([^=]+)=(.+)$/);
|
|
288
|
-
if (match) {
|
|
289
|
-
const key = match[1];
|
|
290
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
291
|
-
redacted[i] = `--${key}=[REDACTED]`;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
return redacted;
|
|
297
|
-
}
|
|
298
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",
|
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: {
|
|
@@ -266,28 +267,4 @@ class UnityEditor {
|
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
|
-
function redactSensitiveArgs(argv, sensitiveKeys = ["password", "token", "secret"]) {
|
|
270
|
-
const redacted = [...argv];
|
|
271
|
-
for (let i = 0; i < redacted.length; i++) {
|
|
272
|
-
const arg = redacted[i];
|
|
273
|
-
if (arg.startsWith("--") || arg.startsWith("-")) {
|
|
274
|
-
const key = arg.replace(/^--?/, "");
|
|
275
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
276
|
-
if (i + 1 < redacted.length && !redacted[i + 1].startsWith("-")) {
|
|
277
|
-
redacted[i + 1] = "[REDACTED]";
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
const match = arg.match(/^--?([^=]+)=(.+)$/);
|
|
283
|
-
if (match) {
|
|
284
|
-
const key = match[1];
|
|
285
|
-
if (sensitiveKeys.includes(key.toLowerCase())) {
|
|
286
|
-
redacted[i] = `--${key}=[REDACTED]`;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return redacted;
|
|
292
|
-
}
|
|
293
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
|
+
}
|