uloop-cli 1.6.4 → 1.7.2
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/dist/cli.bundle.cjs +95 -53
- package/dist/cli.bundle.cjs.map +3 -3
- package/package.json +5 -5
- package/src/__tests__/busy-state-order.test.ts +120 -0
- package/src/__tests__/cli-project-error.test.ts +33 -0
- package/src/__tests__/cli-update.test.ts +129 -0
- package/src/__tests__/port-resolver.test.ts +45 -0
- package/src/__tests__/project-root.test.ts +35 -1
- package/src/cli-project-error.ts +26 -0
- package/src/cli.ts +13 -21
- package/src/default-tools.json +1 -1
- package/src/execute-tool.ts +14 -3
- package/src/port-resolver.ts +39 -38
- package/src/project-root.ts +6 -1
- package/src/version.ts +1 -1
package/dist/cli.bundle.cjs
CHANGED
|
@@ -9,6 +9,10 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
9
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
10
10
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
11
|
};
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
12
16
|
var __copyProps = (to, from, except, desc) => {
|
|
13
17
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
18
|
for (let key of __getOwnPropNames(from))
|
|
@@ -25,6 +29,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
29
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
30
|
mod
|
|
27
31
|
));
|
|
32
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
33
|
|
|
29
34
|
// node_modules/commander/lib/error.js
|
|
30
35
|
var require_error = __commonJS({
|
|
@@ -5382,6 +5387,14 @@ var require_semver2 = __commonJS({
|
|
|
5382
5387
|
}
|
|
5383
5388
|
});
|
|
5384
5389
|
|
|
5390
|
+
// src/cli.ts
|
|
5391
|
+
var cli_exports = {};
|
|
5392
|
+
__export(cli_exports, {
|
|
5393
|
+
getInstalledVersion: () => getInstalledVersion,
|
|
5394
|
+
updateCli: () => updateCli
|
|
5395
|
+
});
|
|
5396
|
+
module.exports = __toCommonJS(cli_exports);
|
|
5397
|
+
|
|
5385
5398
|
// src/cli-constants.ts
|
|
5386
5399
|
var PRODUCT_DISPLAY_NAME = "Unity CLI Loop";
|
|
5387
5400
|
var MENU_PATH_SERVER = "Window > Unity CLI Loop > Server";
|
|
@@ -5605,8 +5618,12 @@ function isUnityProject(dirPath) {
|
|
|
5605
5618
|
const hasProjectSettings = (0, import_fs.existsSync)((0, import_path.join)(dirPath, "ProjectSettings"));
|
|
5606
5619
|
return hasAssets && hasProjectSettings;
|
|
5607
5620
|
}
|
|
5621
|
+
function getUnitySettingsCandidatePaths(dirPath) {
|
|
5622
|
+
const settingsPath = (0, import_path.join)(dirPath, "UserSettings/UnityMcpSettings.json");
|
|
5623
|
+
return [settingsPath, `${settingsPath}.tmp`, `${settingsPath}.bak`];
|
|
5624
|
+
}
|
|
5608
5625
|
function hasUloopInstalled(dirPath) {
|
|
5609
|
-
return (
|
|
5626
|
+
return getUnitySettingsCandidatePaths(dirPath).some((path) => (0, import_fs.existsSync)(path));
|
|
5610
5627
|
}
|
|
5611
5628
|
function isUnityProjectWithUloop(dirPath) {
|
|
5612
5629
|
return isUnityProject(dirPath) && hasUloopInstalled(dirPath);
|
|
@@ -5813,34 +5830,32 @@ Run 'uloop launch -r' to restart Unity.`
|
|
|
5813
5830
|
);
|
|
5814
5831
|
}
|
|
5815
5832
|
async function readPortFromSettingsOrThrow(projectRoot) {
|
|
5816
|
-
const settingsPath
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
if (port === null) {
|
|
5841
|
-
throw createSettingsReadError(projectRoot);
|
|
5833
|
+
for (const settingsPath of getUnitySettingsCandidatePaths(projectRoot)) {
|
|
5834
|
+
let content;
|
|
5835
|
+
try {
|
|
5836
|
+
content = await (0, import_promises.readFile)(settingsPath, "utf-8");
|
|
5837
|
+
} catch {
|
|
5838
|
+
continue;
|
|
5839
|
+
}
|
|
5840
|
+
let parsed;
|
|
5841
|
+
try {
|
|
5842
|
+
parsed = JSON.parse(content);
|
|
5843
|
+
} catch {
|
|
5844
|
+
continue;
|
|
5845
|
+
}
|
|
5846
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
5847
|
+
continue;
|
|
5848
|
+
}
|
|
5849
|
+
const settings = parsed;
|
|
5850
|
+
if (settings.isServerRunning === false) {
|
|
5851
|
+
throw new UnityNotRunningError(projectRoot);
|
|
5852
|
+
}
|
|
5853
|
+
const port = resolvePortFromUnitySettings(settings);
|
|
5854
|
+
if (port !== null) {
|
|
5855
|
+
return port;
|
|
5856
|
+
}
|
|
5842
5857
|
}
|
|
5843
|
-
|
|
5858
|
+
throw createSettingsReadError(projectRoot);
|
|
5844
5859
|
}
|
|
5845
5860
|
|
|
5846
5861
|
// src/project-validator.ts
|
|
@@ -5893,7 +5908,7 @@ var import_path4 = require("path");
|
|
|
5893
5908
|
|
|
5894
5909
|
// src/default-tools.json
|
|
5895
5910
|
var default_tools_default = {
|
|
5896
|
-
version: "1.
|
|
5911
|
+
version: "1.7.2",
|
|
5897
5912
|
tools: [
|
|
5898
5913
|
{
|
|
5899
5914
|
name: "compile",
|
|
@@ -6526,7 +6541,7 @@ function getCachedServerVersion() {
|
|
|
6526
6541
|
}
|
|
6527
6542
|
|
|
6528
6543
|
// src/version.ts
|
|
6529
|
-
var VERSION = "1.
|
|
6544
|
+
var VERSION = "1.7.2";
|
|
6530
6545
|
|
|
6531
6546
|
// src/spinner.ts
|
|
6532
6547
|
var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
@@ -6862,6 +6877,12 @@ function checkUnityBusyState(projectPath) {
|
|
|
6862
6877
|
throw new Error("UNITY_SERVER_STARTING");
|
|
6863
6878
|
}
|
|
6864
6879
|
}
|
|
6880
|
+
function checkUnityBusyStateBeforeProjectResolution(globalOptions) {
|
|
6881
|
+
if (globalOptions.port !== void 0) {
|
|
6882
|
+
return;
|
|
6883
|
+
}
|
|
6884
|
+
checkUnityBusyState(globalOptions.projectPath);
|
|
6885
|
+
}
|
|
6865
6886
|
async function executeToolCommand(toolName, params, globalOptions) {
|
|
6866
6887
|
let portNumber;
|
|
6867
6888
|
if (globalOptions.port) {
|
|
@@ -6871,6 +6892,7 @@ async function executeToolCommand(toolName, params, globalOptions) {
|
|
|
6871
6892
|
}
|
|
6872
6893
|
portNumber = parsed;
|
|
6873
6894
|
}
|
|
6895
|
+
checkUnityBusyStateBeforeProjectResolution(globalOptions);
|
|
6874
6896
|
const port = await resolveUnityPort(portNumber, globalOptions.projectPath);
|
|
6875
6897
|
const compileOptions = getCompileExecutionOptions(toolName, params);
|
|
6876
6898
|
const shouldWaitForDomainReload = compileOptions.waitForDomainReload;
|
|
@@ -6883,7 +6905,7 @@ async function executeToolCommand(toolName, params, globalOptions) {
|
|
|
6883
6905
|
const shouldValidateProject = portNumber === void 0 && projectRoot !== null;
|
|
6884
6906
|
let requestDispatched = false;
|
|
6885
6907
|
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
6886
|
-
|
|
6908
|
+
checkUnityBusyStateBeforeProjectResolution(globalOptions);
|
|
6887
6909
|
const client = new DirectUnityClient(port);
|
|
6888
6910
|
try {
|
|
6889
6911
|
await client.connect();
|
|
@@ -7000,6 +7022,7 @@ async function listAvailableTools(globalOptions) {
|
|
|
7000
7022
|
}
|
|
7001
7023
|
portNumber = parsed;
|
|
7002
7024
|
}
|
|
7025
|
+
checkUnityBusyStateBeforeProjectResolution(globalOptions);
|
|
7003
7026
|
const port = await resolveUnityPort(portNumber, globalOptions.projectPath);
|
|
7004
7027
|
const projectRoot = globalOptions.projectPath !== void 0 ? validateProjectPath(globalOptions.projectPath) : findUnityProjectRoot();
|
|
7005
7028
|
const shouldValidateProject = portNumber === void 0 && projectRoot !== null;
|
|
@@ -7007,7 +7030,7 @@ async function listAvailableTools(globalOptions) {
|
|
|
7007
7030
|
const spinner = createSpinner("Connecting to Unity...");
|
|
7008
7031
|
let lastError;
|
|
7009
7032
|
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
7010
|
-
|
|
7033
|
+
checkUnityBusyStateBeforeProjectResolution(globalOptions);
|
|
7011
7034
|
const client = new DirectUnityClient(port);
|
|
7012
7035
|
try {
|
|
7013
7036
|
await client.connect();
|
|
@@ -7062,6 +7085,7 @@ async function syncTools(globalOptions) {
|
|
|
7062
7085
|
}
|
|
7063
7086
|
portNumber = parsed;
|
|
7064
7087
|
}
|
|
7088
|
+
checkUnityBusyStateBeforeProjectResolution(globalOptions);
|
|
7065
7089
|
const port = await resolveUnityPort(portNumber, globalOptions.projectPath);
|
|
7066
7090
|
const projectRoot = globalOptions.projectPath !== void 0 ? validateProjectPath(globalOptions.projectPath) : findUnityProjectRoot();
|
|
7067
7091
|
const shouldValidateProject = portNumber === void 0 && projectRoot !== null;
|
|
@@ -7069,7 +7093,7 @@ async function syncTools(globalOptions) {
|
|
|
7069
7093
|
const spinner = createSpinner("Connecting to Unity...");
|
|
7070
7094
|
let lastError;
|
|
7071
7095
|
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
7072
|
-
|
|
7096
|
+
checkUnityBusyStateBeforeProjectResolution(globalOptions);
|
|
7073
7097
|
const client = new DirectUnityClient(port);
|
|
7074
7098
|
try {
|
|
7075
7099
|
await client.connect();
|
|
@@ -9010,6 +9034,28 @@ function registerFocusWindowCommand(program3, helpGroup) {
|
|
|
9010
9034
|
});
|
|
9011
9035
|
}
|
|
9012
9036
|
|
|
9037
|
+
// src/cli-project-error.ts
|
|
9038
|
+
function getProjectResolutionErrorLines(error) {
|
|
9039
|
+
if (error instanceof UnityNotRunningError) {
|
|
9040
|
+
return [
|
|
9041
|
+
"Error: Unity Editor for this project is not running.",
|
|
9042
|
+
"",
|
|
9043
|
+
` Project: ${error.projectRoot}`,
|
|
9044
|
+
"",
|
|
9045
|
+
"Start the Unity Editor for this project and try again."
|
|
9046
|
+
];
|
|
9047
|
+
}
|
|
9048
|
+
return [
|
|
9049
|
+
"Error: Connected Unity instance belongs to a different project.",
|
|
9050
|
+
"",
|
|
9051
|
+
` Project: ${error.expectedProjectRoot}`,
|
|
9052
|
+
` Connected to: ${error.connectedProjectRoot}`,
|
|
9053
|
+
"",
|
|
9054
|
+
"Another Unity instance was found, but it belongs to a different project.",
|
|
9055
|
+
"Start the Unity Editor for this project, or use --project-path to specify the target."
|
|
9056
|
+
];
|
|
9057
|
+
}
|
|
9058
|
+
|
|
9013
9059
|
// src/cli.ts
|
|
9014
9060
|
var FOCUS_WINDOW_COMMAND = "focus-window";
|
|
9015
9061
|
var LAUNCH_COMMAND = "launch";
|
|
@@ -9271,23 +9317,15 @@ async function runWithErrorHandling(fn) {
|
|
|
9271
9317
|
await fn();
|
|
9272
9318
|
} catch (error) {
|
|
9273
9319
|
if (error instanceof UnityNotRunningError) {
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
console.error("");
|
|
9278
|
-
console.error("Start the Unity Editor for this project and try again.");
|
|
9320
|
+
for (const line of getProjectResolutionErrorLines(error)) {
|
|
9321
|
+
console.error(line.startsWith("Error: ") ? `\x1B[31m${line}\x1B[0m` : line);
|
|
9322
|
+
}
|
|
9279
9323
|
process.exit(1);
|
|
9280
9324
|
}
|
|
9281
9325
|
if (error instanceof ProjectMismatchError) {
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
console.error(` Connected to: ${error.connectedProjectRoot}`);
|
|
9286
|
-
console.error("");
|
|
9287
|
-
console.error("Another Unity instance was found, but it belongs to a different project.");
|
|
9288
|
-
console.error(
|
|
9289
|
-
"Start the Unity Editor for this project, or use --project-path to specify the target."
|
|
9290
|
-
);
|
|
9326
|
+
for (const line of getProjectResolutionErrorLines(error)) {
|
|
9327
|
+
console.error(line.startsWith("Error: ") ? `\x1B[31m${line}\x1B[0m` : line);
|
|
9328
|
+
}
|
|
9291
9329
|
process.exit(1);
|
|
9292
9330
|
}
|
|
9293
9331
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -9410,9 +9448,7 @@ compdef _uloop uloop`;
|
|
|
9410
9448
|
}
|
|
9411
9449
|
function getInstalledVersion(callback) {
|
|
9412
9450
|
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
9413
|
-
const child = (0, import_child_process.spawn)(npmCommand, ["list", "-g", "uloop-cli", "--json"]
|
|
9414
|
-
shell: true
|
|
9415
|
-
});
|
|
9451
|
+
const child = (0, import_child_process.spawn)(npmCommand, ["list", "-g", "uloop-cli", "--json"]);
|
|
9416
9452
|
let stdout = "";
|
|
9417
9453
|
child.stdout.on("data", (data) => {
|
|
9418
9454
|
stdout += data.toString();
|
|
@@ -9459,8 +9495,7 @@ function updateCli() {
|
|
|
9459
9495
|
console.log("Updating uloop-cli to the latest version...");
|
|
9460
9496
|
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
9461
9497
|
const child = (0, import_child_process.spawn)(npmCommand, ["install", "-g", "uloop-cli@latest"], {
|
|
9462
|
-
stdio: "inherit"
|
|
9463
|
-
shell: true
|
|
9498
|
+
stdio: "inherit"
|
|
9464
9499
|
});
|
|
9465
9500
|
child.on("close", (code) => {
|
|
9466
9501
|
if (code === 0) {
|
|
@@ -9753,5 +9788,12 @@ async function main() {
|
|
|
9753
9788
|
}
|
|
9754
9789
|
program2.parse();
|
|
9755
9790
|
}
|
|
9756
|
-
void
|
|
9791
|
+
if (process.env.JEST_WORKER_ID === void 0) {
|
|
9792
|
+
void main();
|
|
9793
|
+
}
|
|
9794
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
9795
|
+
0 && (module.exports = {
|
|
9796
|
+
getInstalledVersion,
|
|
9797
|
+
updateCli
|
|
9798
|
+
});
|
|
9757
9799
|
//# sourceMappingURL=cli.bundle.cjs.map
|