@rage-against-the-pixel/unity-cli 3.0.1 → 4.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 (60) hide show
  1. package/README.md +89 -223
  2. package/dist/android-sdk.js +8 -1
  3. package/dist/android-sdk.js.map +1 -1
  4. package/dist/cli.js +195 -506
  5. package/dist/cli.js.map +1 -1
  6. package/dist/failure-markers.d.ts +17 -0
  7. package/dist/failure-markers.js +46 -0
  8. package/dist/failure-markers.js.map +1 -0
  9. package/dist/github-actions-ci.d.ts +1 -0
  10. package/dist/github-actions-ci.js +17 -3
  11. package/dist/github-actions-ci.js.map +1 -1
  12. package/dist/index.d.ts +2 -2
  13. package/dist/index.js +2 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/license-client.d.ts +113 -2
  16. package/dist/license-client.js +715 -54
  17. package/dist/license-client.js.map +1 -1
  18. package/dist/logger-provider.d.ts +2 -0
  19. package/dist/logger-provider.js +3 -0
  20. package/dist/logger-provider.js.map +1 -1
  21. package/dist/logging.d.ts +6 -1
  22. package/dist/logging.js +66 -5
  23. package/dist/logging.js.map +1 -1
  24. package/dist/process-tracker.d.ts +71 -0
  25. package/dist/process-tracker.js +213 -0
  26. package/dist/process-tracker.js.map +1 -0
  27. package/dist/unity-cli.d.ts +97 -0
  28. package/dist/unity-cli.js +587 -0
  29. package/dist/unity-cli.js.map +1 -0
  30. package/dist/unity-editor.d.ts +25 -16
  31. package/dist/unity-editor.js +204 -107
  32. package/dist/unity-editor.js.map +1 -1
  33. package/dist/unity-installer.d.ts +134 -0
  34. package/dist/unity-installer.js +963 -0
  35. package/dist/unity-installer.js.map +1 -0
  36. package/dist/unity-logging.d.ts +16 -1
  37. package/dist/unity-logging.js +79 -40
  38. package/dist/unity-logging.js.map +1 -1
  39. package/dist/unity-project.d.ts +15 -0
  40. package/dist/unity-project.js +80 -0
  41. package/dist/unity-project.js.map +1 -1
  42. package/dist/unity-version.d.ts +4 -0
  43. package/dist/unity-version.js +40 -2
  44. package/dist/unity-version.js.map +1 -1
  45. package/dist/upm-cli.d.ts +8 -8
  46. package/dist/upm-cli.js +8 -8
  47. package/dist/upm-cli.js.map +1 -1
  48. package/dist/utilities.d.ts +27 -7
  49. package/dist/utilities.js +119 -63
  50. package/dist/utilities.js.map +1 -1
  51. package/dist/utp-benign.d.ts +13 -0
  52. package/dist/utp-benign.js +41 -0
  53. package/dist/utp-benign.js.map +1 -0
  54. package/dist/utp.d.ts +11 -2
  55. package/dist/utp.js +40 -3
  56. package/dist/utp.js.map +1 -1
  57. package/package.json +14 -15
  58. package/dist/unity-hub.d.ts +0 -127
  59. package/dist/unity-hub.js +0 -1327
  60. package/dist/unity-hub.js.map +0 -1
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.OwnedSpawnOptions = OwnedSpawnOptions;
37
+ exports.ReadOwnedRoots = ReadOwnedRoots;
38
+ exports.TrackOwnedProcess = TrackOwnedProcess;
39
+ exports.ListProcesses = ListProcesses;
40
+ exports.SelectOwnedProcesses = SelectOwnedProcesses;
41
+ exports.ParseElapsedSeconds = ParseElapsedSeconds;
42
+ exports.FindOwnedProcesses = FindOwnedProcesses;
43
+ exports.IsExecutableNamed = IsExecutableNamed;
44
+ exports.IsPathUnder = IsPathUnder;
45
+ const fs = __importStar(require("fs"));
46
+ const path = __importStar(require("path"));
47
+ const logging_1 = require("./logging");
48
+ const utilities_1 = require("./utilities");
49
+ const logger = logging_1.Logger.instance;
50
+ /** Options that make a spawned process lead its own process group on macOS and Linux. */
51
+ function OwnedSpawnOptions() {
52
+ return { detached: process.platform !== 'win32' };
53
+ }
54
+ function stateFilePath() {
55
+ return path.join((0, utilities_1.GetTempDir)(), 'unity-cli-owned-processes.json');
56
+ }
57
+ /** The processes recorded by this job's earlier and current commands. */
58
+ function ReadOwnedRoots() {
59
+ try {
60
+ const roots = JSON.parse(fs.readFileSync(stateFilePath(), 'utf-8'));
61
+ return Array.isArray(roots)
62
+ ? roots.filter((root) => Number.isInteger(root?.pid) && Number.isFinite(root?.startedAt))
63
+ : [];
64
+ }
65
+ catch {
66
+ return [];
67
+ }
68
+ }
69
+ /**
70
+ * Records a process this command started. Only done in CI, where cleanup runs.
71
+ * @param child The spawned process, started with {@link OwnedSpawnOptions}.
72
+ * @param startedAt When it was spawned, in milliseconds since the epoch.
73
+ */
74
+ function TrackOwnedProcess(child, startedAt) {
75
+ if (process.env.CI !== 'true' || !child.pid) {
76
+ return;
77
+ }
78
+ try {
79
+ const roots = ReadOwnedRoots().filter(root => root.pid !== child.pid);
80
+ roots.push({ pid: child.pid, startedAt });
81
+ fs.writeFileSync(stateFilePath(), JSON.stringify(roots), { encoding: 'utf-8', mode: 0o600 });
82
+ }
83
+ catch (error) {
84
+ logger.debug(`Failed to record process ${child.pid}: ${error}`);
85
+ }
86
+ }
87
+ /** Lists running processes with their group, creation time and command line. */
88
+ async function ListProcesses() {
89
+ const results = [];
90
+ try {
91
+ if (process.platform === 'win32') {
92
+ const output = await (0, utilities_1.Exec)('powershell', [
93
+ '-NoProfile',
94
+ '-Command',
95
+ 'Get-CimInstance Win32_Process | ForEach-Object { $c = if ($_.CreationDate) { ([DateTimeOffset]$_.CreationDate).ToUnixTimeMilliseconds() } else { 0 }; "$($_.ProcessId)`t$($_.ParentProcessId)`t$c`t$($_.Name)`t$($_.ExecutablePath)`t$($_.CommandLine)" }'
96
+ ], { silent: true, showCommand: false });
97
+ for (const line of output.split(/\r?\n/)) {
98
+ const [pid, ppid, created, name, executable, ...commandLine] = line.split('\t');
99
+ if (pid && ppid && /^\d+$/.test(pid)) {
100
+ results.push({
101
+ pid: parseInt(pid, 10),
102
+ ppid: parseInt(ppid, 10),
103
+ createdAt: parseInt(created ?? '0', 10) || 0,
104
+ name: name ?? '',
105
+ executablePath: executable || undefined,
106
+ commandLine: commandLine.join('\t'),
107
+ });
108
+ }
109
+ }
110
+ }
111
+ else {
112
+ // etime is the elapsed time as [[dd-]hh:]mm:ss, which both macOS and Linux ps report
113
+ const output = await (0, utilities_1.Exec)('ps', ['-axo', 'pid=,ppid=,pgid=,etime=,args='], { silent: true, showCommand: false });
114
+ const now = Date.now();
115
+ for (const line of output.split('\n')) {
116
+ const match = /^\s*(\d+)\s+(\d+)\s+(\d+)\s+([\d:-]+)\s+(.*)$/.exec(line);
117
+ if (match) {
118
+ results.push({
119
+ pid: parseInt(match[1], 10),
120
+ ppid: parseInt(match[2], 10),
121
+ pgid: parseInt(match[3], 10),
122
+ createdAt: now - ParseElapsedSeconds(match[4]) * 1000,
123
+ name: match[5],
124
+ commandLine: match[5],
125
+ });
126
+ }
127
+ }
128
+ }
129
+ }
130
+ catch (error) {
131
+ logger.debug(`Failed to list processes: ${error}`);
132
+ }
133
+ return results.filter(proc => proc.pid !== process.pid);
134
+ }
135
+ /**
136
+ * The running processes that belong to the given roots: on macOS and Linux every member of their process groups, on
137
+ * Windows the roots and their descendants created after the root started.
138
+ * @param roots The processes unity-cli started.
139
+ * @param processes A process list from {@link ListProcesses}.
140
+ */
141
+ function SelectOwnedProcesses(roots, processes) {
142
+ if (roots.length === 0) {
143
+ return [];
144
+ }
145
+ // a dead process's id can be reused by another job, so a member must be no older than the root it belongs to;
146
+ // ps reports whole seconds, hence the slack
147
+ const earliest = Math.min(...roots.map(root => root.startedAt)) - 2000;
148
+ if (process.platform !== 'win32') {
149
+ const groups = new Map(roots.map(root => [root.pid, root.startedAt - 2000]));
150
+ return processes.filter(proc => proc.pgid !== undefined && groups.has(proc.pgid) &&
151
+ (proc.createdAt === undefined || proc.createdAt >= groups.get(proc.pgid)));
152
+ }
153
+ const owned = new Map();
154
+ let frontier = new Set(roots.map(root => root.pid));
155
+ for (const proc of processes) {
156
+ if (frontier.has(proc.pid) && (proc.createdAt ?? 0) >= earliest) {
157
+ owned.set(proc.pid, proc);
158
+ }
159
+ }
160
+ while (frontier.size > 0) {
161
+ const next = new Set();
162
+ for (const proc of processes) {
163
+ if (!owned.has(proc.pid) && frontier.has(proc.ppid) && (proc.createdAt ?? 0) >= earliest) {
164
+ owned.set(proc.pid, proc);
165
+ next.add(proc.pid);
166
+ }
167
+ }
168
+ frontier = next;
169
+ }
170
+ return [...owned.values()];
171
+ }
172
+ /**
173
+ * Converts a ps elapsed time, [[dd-]hh:]mm:ss, to seconds.
174
+ * @param elapsed The etime value.
175
+ */
176
+ function ParseElapsedSeconds(elapsed) {
177
+ const [days, clock] = elapsed.includes('-') ? elapsed.split('-', 2) : ['0', elapsed];
178
+ const parts = clock.split(':').map(part => parseInt(part, 10) || 0);
179
+ while (parts.length < 3) {
180
+ parts.unshift(0);
181
+ }
182
+ return (parseInt(days, 10) || 0) * 86400 + parts[0] * 3600 + parts[1] * 60 + parts[2];
183
+ }
184
+ /** The running processes this job's unity-cli commands started, and their helpers. */
185
+ async function FindOwnedProcesses() {
186
+ const roots = ReadOwnedRoots();
187
+ return roots.length === 0 ? [] : SelectOwnedProcesses(roots, await ListProcesses());
188
+ }
189
+ /**
190
+ * Whether a process's executable is the named one, e.g. Unity.Licensing.Client.
191
+ * @param proc The process.
192
+ * @param name The executable file name, without .exe.
193
+ */
194
+ function IsExecutableNamed(proc, name) {
195
+ const target = name.toLowerCase();
196
+ const executable = (proc.executablePath ?? proc.commandLine.split(' ')[0] ?? proc.name).toLowerCase();
197
+ return path.basename(executable).replace(/\.exe$/, '') === target || proc.name.toLowerCase().replace(/\.exe$/, '') === target;
198
+ }
199
+ /**
200
+ * Whether a path lies inside a directory, compared on whole path segments.
201
+ * @param candidate The path to check.
202
+ * @param directory The directory.
203
+ */
204
+ function IsPathUnder(candidate, directory) {
205
+ const normalize = (value) => {
206
+ const resolved = path.resolve(value);
207
+ return process.platform === 'win32' || process.platform === 'darwin' ? resolved.toLowerCase() : resolved;
208
+ };
209
+ const root = normalize(directory);
210
+ const target = normalize(candidate);
211
+ return target === root || target.startsWith(root.endsWith(path.sep) ? root : root + path.sep);
212
+ }
213
+ //# sourceMappingURL=process-tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-tracker.js","sourceRoot":"","sources":["../src/process-tracker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,8CAEC;AAOD,wCASC;AAOD,8CAYC;AAGD,sCAkDC;AAQD,oDAqCC;AAMD,kDASC;AAGD,gDAGC;AAOD,8CAIC;AAOD,kCAQC;AA/ND,uCAAyB;AACzB,2CAA6B;AAE7B,uCAAmC;AACnC,2CAAyD;AAkCzD,MAAM,MAAM,GAAG,gBAAM,CAAC,QAAQ,CAAC;AAE/B,yFAAyF;AACzF,SAAgB,iBAAiB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,QAAQ,CAAC;IAC7G,CAAC,CAAC;IACF,MAAM,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AAClG,CAAC"}
@@ -0,0 +1,97 @@
1
+ export interface UnityCliResult {
2
+ exitCode: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ }
6
+ /** The envelope every `--format json` result of the official CLI uses. */
7
+ export interface UnityCliEnvelope<T = unknown> {
8
+ success: boolean;
9
+ command?: string;
10
+ data?: T;
11
+ errors?: {
12
+ code: string;
13
+ message: string;
14
+ }[];
15
+ warnings?: unknown[];
16
+ }
17
+ export interface UnityCliRunOptions {
18
+ /** Stream output to the console. Defaults to false. */
19
+ stream?: boolean;
20
+ /** Kill the CLI after this many milliseconds. */
21
+ timeoutMs?: number;
22
+ /** Values replaced with `*****` in logged output and the logged command. */
23
+ redactLiterals?: readonly string[];
24
+ }
25
+ /**
26
+ * A thin wrapper over Unity's official CLI (`unity`).
27
+ * @see https://docs.unity.com/en-us/cli
28
+ */
29
+ export declare class UnityCli {
30
+ readonly executable: string;
31
+ readonly version: string;
32
+ private readonly logger;
33
+ constructor(executable: string, version: string);
34
+ /**
35
+ * Returns the official Unity CLI, installing it when it is missing or is not the requested version.
36
+ * @param version An exact version such as 1.0.0-beta.14, or `latest`. Defaults to UNITY_CLI_VERSION, then `latest`.
37
+ * Every install exports UNITY_CLI_VERSION, so later steps in the same job reuse the version the first one resolved.
38
+ */
39
+ static Get(version?: string | undefined): Promise<UnityCli>;
40
+ /**
41
+ * Finds an installed official Unity CLI from UNITY_CLI_PATH, the tool cache, the install script's default location, or the PATH.
42
+ * The PATH comes last, since other programs named unity live there, such as the Unity7 shell on Ubuntu desktops.
43
+ */
44
+ static Find(): Promise<UnityCli | undefined>;
45
+ /**
46
+ * Downloads an exact official Unity CLI release from Unity's CDN, verifies its SHA-256 and caches it.
47
+ * @param version An exact version such as 1.0.0-beta.14, or `latest`.
48
+ */
49
+ static Install(version?: string): Promise<UnityCli>;
50
+ /**
51
+ * Runs the CLI and returns its exit code and output without throwing on a non-zero exit code.
52
+ * @param args The arguments to pass to `unity`.
53
+ * @param options Run options.
54
+ */
55
+ Run(args: string[], options?: UnityCliRunOptions): Promise<UnityCliResult>;
56
+ /**
57
+ * Runs the CLI and throws when it exits with a non-zero exit code.
58
+ * @param args The arguments to pass to `unity`.
59
+ * @param options Run options. Output streams to the console unless `stream` is false.
60
+ */
61
+ Exec(args: string[], options?: UnityCliRunOptions): Promise<string>;
62
+ /**
63
+ * Runs the CLI with `--format json` and parses the result envelope from stdout.
64
+ * @param args The arguments to pass to `unity`.
65
+ * @param options Run options.
66
+ * @returns The exit code and the parsed envelope, if stdout held one.
67
+ */
68
+ RunJson<T = unknown>(args: string[], options?: UnityCliRunOptions): Promise<{
69
+ exitCode: number;
70
+ envelope: UnityCliEnvelope<T> | undefined;
71
+ stdout: string;
72
+ stderr: string;
73
+ }>;
74
+ /**
75
+ * Runs the CLI with `--format json` and returns `data`, throwing when the command fails.
76
+ * @param args The arguments to pass to `unity`.
77
+ * @param options Run options.
78
+ */
79
+ ExecJson<T = unknown>(args: string[], options?: UnityCliRunOptions): Promise<T>;
80
+ /** Gets the directory the CLI installs editors to. */
81
+ GetInstallPath(): Promise<string>;
82
+ /**
83
+ * Sets the directory the CLI installs editors to.
84
+ * @param installPath The directory to install editors to.
85
+ */
86
+ SetInstallPath(installPath: string): Promise<void>;
87
+ /**
88
+ * Gets the path to the Unity.Licensing.Client the CLI manages, downloading it first if needed.
89
+ * @returns The licensing client executable, or undefined when the CLI does not report one.
90
+ */
91
+ GetLicensingClientPath(): Promise<string | undefined>;
92
+ }
93
+ /**
94
+ * Finds the first absolute path in a CLI result, preferring well-known keys.
95
+ * @param value A parsed CLI JSON value.
96
+ */
97
+ export declare function FindAbsolutePath(value: unknown): string | undefined;