@rage-against-the-pixel/unity-cli 1.8.3 → 3.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.
- package/README.md +128 -66
- package/dist/cli.js +264 -34
- package/dist/cli.js.map +1 -1
- package/dist/github-actions-ci.d.ts +21 -0
- package/dist/github-actions-ci.js +137 -0
- package/dist/github-actions-ci.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger-provider.d.ts +35 -0
- package/dist/logger-provider.js +48 -0
- package/dist/logger-provider.js.map +1 -0
- package/dist/logging.d.ts +89 -4
- package/dist/logging.js +780 -186
- package/dist/logging.js.map +1 -1
- package/dist/unity-editor.d.ts +12 -0
- package/dist/unity-editor.js +75 -16
- package/dist/unity-editor.js.map +1 -1
- package/dist/unity-hub.d.ts +21 -1
- package/dist/unity-hub.js +197 -90
- package/dist/unity-hub.js.map +1 -1
- package/dist/unity-logging.d.ts +23 -1
- package/dist/unity-logging.js +259 -12
- package/dist/unity-logging.js.map +1 -1
- package/dist/upm-cli.d.ts +86 -0
- package/dist/upm-cli.js +469 -0
- package/dist/upm-cli.js.map +1 -0
- package/dist/utilities.d.ts +52 -0
- package/dist/utilities.js +195 -13
- package/dist/utilities.js.map +1 -1
- package/dist/{utp/utp.d.ts → utp.d.ts} +21 -3
- package/dist/{utp/utp.js → utp.js} +25 -12
- package/dist/utp.js.map +1 -0
- package/package.json +20 -9
- package/dist/utp/utp.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -53,16 +53,93 @@ const child_process_1 = require("child_process");
|
|
|
53
53
|
const android_sdk_1 = require("./android-sdk");
|
|
54
54
|
const license_client_1 = require("./license-client");
|
|
55
55
|
const utilities_1 = require("./utilities");
|
|
56
|
+
const upm_cli_1 = require("./upm-cli");
|
|
56
57
|
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
57
58
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
58
59
|
(0, update_notifier_1.default)({ pkg }).notify();
|
|
59
60
|
const program = new commander_1.Command();
|
|
60
61
|
program.name('unity-cli')
|
|
61
|
-
.description('A command line utility for the Unity Game Engine.')
|
|
62
|
+
.description('A powerful all-in-one command line utility for the Unity Game Engine.')
|
|
62
63
|
.version(pkg.version);
|
|
64
|
+
program.command('install-all-tools')
|
|
65
|
+
.description('Install the Unity Hub and the Unity Package Manager cli (pack/sign). Runs hub-install and upm-install in parallel.')
|
|
66
|
+
.option('--verbose', 'Enable verbose logging.')
|
|
67
|
+
.option('--auto-update', 'If any tools are installed, they\'re automatically updated to the latest versions. Cannot be used with --hub-version or --upm-version.')
|
|
68
|
+
.option('--hub-version <version>', 'Specify to install a specific version of Unity Hub. Cannot be used with --auto-update.')
|
|
69
|
+
.option('--upm-version <version>', 'Specify to install a specific version of the Unity Package Manager cli. Cannot be used with --auto-update.')
|
|
70
|
+
.option('--json', 'Print hub path, UPM CLI version, and resolved UPM CLI path as JSON.')
|
|
71
|
+
.action(async (options) => {
|
|
72
|
+
if (options.verbose) {
|
|
73
|
+
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
74
|
+
}
|
|
75
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
76
|
+
if (options.autoUpdate === true && options.hubVersion) {
|
|
77
|
+
logging_1.Logger.instance.error('Cannot use --auto-update with --hub-version.');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
if (options.autoUpdate === true && options.upmVersion) {
|
|
81
|
+
logging_1.Logger.instance.error('Cannot use --auto-update with --upm-version.');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const unityHub = new unity_hub_1.UnityHub();
|
|
86
|
+
const upm = new upm_cli_1.UpmCli();
|
|
87
|
+
let upmRequestedVersion = options.upmVersion?.toString()?.trim();
|
|
88
|
+
if (options.autoUpdate === true) {
|
|
89
|
+
const currentVersion = upm.GetInstalledReleaseTag();
|
|
90
|
+
const latestVersion = await upm.GetLatestReleaseTag();
|
|
91
|
+
if (currentVersion && !upm.IsUpdateAvailable(latestVersion)) {
|
|
92
|
+
logging_1.Logger.instance.info(`Upm cli is already up to date (${currentVersion}).`);
|
|
93
|
+
upmRequestedVersion = currentVersion;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (currentVersion) {
|
|
97
|
+
logging_1.Logger.instance.info(`Updating upm cli ${currentVersion} -> ${latestVersion}...`);
|
|
98
|
+
}
|
|
99
|
+
upmRequestedVersion = latestVersion;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const [hubPath, upmVer] = await Promise.all([
|
|
103
|
+
unityHub.Install(options.autoUpdate === true, options.hubVersion),
|
|
104
|
+
upm.Install({
|
|
105
|
+
version: upmRequestedVersion,
|
|
106
|
+
skipIfInstalled: true
|
|
107
|
+
}),
|
|
108
|
+
]);
|
|
109
|
+
logging_1.Logger.instance.CI_setEnvironmentVariable('UNITY_HUB_PATH', hubPath);
|
|
110
|
+
let upmCliPath;
|
|
111
|
+
try {
|
|
112
|
+
await upm.Version(upmVer);
|
|
113
|
+
upmCliPath = upm.executable;
|
|
114
|
+
}
|
|
115
|
+
catch (verifyError) {
|
|
116
|
+
logging_1.Logger.instance.warn(`Upm cli version check failed after install: ${verifyError}`);
|
|
117
|
+
if (process.env.CI === 'true') {
|
|
118
|
+
logging_1.Logger.instance.error('Failing in CI because the installed UPM CLI did not match the expected release.');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
upmCliPath = upm.ResolveManagedPrimaryPath();
|
|
122
|
+
}
|
|
123
|
+
if (options.json) {
|
|
124
|
+
process.stdout.write(`\n${JSON.stringify({
|
|
125
|
+
UNITY_HUB_PATH: hubPath,
|
|
126
|
+
UPM_VERSION: upmVer,
|
|
127
|
+
UPM_CLI_PATH: upmCliPath,
|
|
128
|
+
})}\n`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
process.stdout.write(`Unity Hub: ${hubPath}\nUpm cli: ${upmVer}\n${upmCliPath ?? ''}\n`);
|
|
132
|
+
}
|
|
133
|
+
process.exit(0);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
logging_1.Logger.instance.error(`${error}`);
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
63
140
|
program.commandsGroup('Auth:');
|
|
64
141
|
program.command('license-version')
|
|
65
|
-
.description('Print the
|
|
142
|
+
.description('Print the Unity License Client version.')
|
|
66
143
|
.action(async () => {
|
|
67
144
|
const client = new license_client_1.LicensingClient();
|
|
68
145
|
await client.Version();
|
|
@@ -81,7 +158,7 @@ program.command('activate-license')
|
|
|
81
158
|
if (options.verbose) {
|
|
82
159
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
83
160
|
}
|
|
84
|
-
logging_1.Logger.instance.
|
|
161
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
85
162
|
const client = new license_client_1.LicensingClient();
|
|
86
163
|
const licenseStr = options.license?.toString()?.trim();
|
|
87
164
|
if (!licenseStr || licenseStr.length === 0) {
|
|
@@ -103,6 +180,10 @@ program.command('activate-license')
|
|
|
103
180
|
if (licenseType === license_client_1.LicenseType.professional && !options.serial) {
|
|
104
181
|
options.serial = await (0, utilities_1.PromptForSecretInput)('Serial: ');
|
|
105
182
|
}
|
|
183
|
+
// Mask credentials in CI environments before any potential logging
|
|
184
|
+
logging_1.Logger.instance.maskCredential(options.email);
|
|
185
|
+
logging_1.Logger.instance.maskCredential(options.password);
|
|
186
|
+
logging_1.Logger.instance.maskCredential(options.serial);
|
|
106
187
|
}
|
|
107
188
|
const token = await client.Activate({
|
|
108
189
|
licenseType,
|
|
@@ -119,13 +200,13 @@ program.command('activate-license')
|
|
|
119
200
|
program.command('return-license')
|
|
120
201
|
.description('Return a Unity license.')
|
|
121
202
|
.option('-l, --license <license>', 'License type (personal, professional, floating)')
|
|
122
|
-
.option('-t, --token <token>', '
|
|
203
|
+
.option('-t, --token <token>', 'Floating license token. Required when returning a floating license.')
|
|
123
204
|
.option('--verbose', 'Enable verbose logging.')
|
|
124
205
|
.action(async (options) => {
|
|
125
206
|
if (options.verbose) {
|
|
126
207
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
127
208
|
}
|
|
128
|
-
logging_1.Logger.instance.
|
|
209
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
129
210
|
const client = new license_client_1.LicensingClient();
|
|
130
211
|
const licenseStr = options.license?.toString()?.trim();
|
|
131
212
|
if (!licenseStr || licenseStr.length === 0) {
|
|
@@ -146,12 +227,14 @@ program.command('return-license')
|
|
|
146
227
|
logging_1.Logger.instance.error('Token is required when returning a floating license. Use -t or --token to specify it.');
|
|
147
228
|
process.exit(1);
|
|
148
229
|
}
|
|
230
|
+
// Mask token in CI environments before any potential logging
|
|
231
|
+
logging_1.Logger.instance.maskCredential(token);
|
|
149
232
|
}
|
|
150
233
|
await client.Deactivate(licenseType, token);
|
|
151
234
|
process.exit(0);
|
|
152
235
|
});
|
|
153
236
|
program.command('license-context')
|
|
154
|
-
.description('
|
|
237
|
+
.description('Print the current license context information.')
|
|
155
238
|
.action(async () => {
|
|
156
239
|
const client = new license_client_1.LicensingClient();
|
|
157
240
|
await client.Context();
|
|
@@ -164,14 +247,14 @@ program.command('licensing-client-logs')
|
|
|
164
247
|
process.exit(0);
|
|
165
248
|
});
|
|
166
249
|
program.command('licensing-audit-logs')
|
|
167
|
-
.description('Prints the path to the Unity Licensing Client audit log
|
|
250
|
+
.description('Prints the path to the Unity Licensing Client audit log.')
|
|
168
251
|
.action(async () => {
|
|
169
252
|
process.stdout.write(`${license_client_1.LicensingClient.ClientAuditLogPath()}\n`);
|
|
170
253
|
process.exit(0);
|
|
171
254
|
});
|
|
172
255
|
program.commandsGroup('Unity Hub:');
|
|
173
256
|
program.command('hub-version')
|
|
174
|
-
.description('Print the
|
|
257
|
+
.description('Print the Unity Hub version.')
|
|
175
258
|
.action(async () => {
|
|
176
259
|
const unityHub = new unity_hub_1.UnityHub();
|
|
177
260
|
try {
|
|
@@ -212,7 +295,7 @@ program.command('package-manager-logs')
|
|
|
212
295
|
process.exit(0);
|
|
213
296
|
});
|
|
214
297
|
program.command('hub-install')
|
|
215
|
-
.description('Install the Unity Hub.')
|
|
298
|
+
.description('Install or update the Unity Hub.')
|
|
216
299
|
.option('--verbose', 'Enable verbose logging.')
|
|
217
300
|
.option('--auto-update', 'Automatically updates the Unity Hub if it is already installed. Cannot be used with --hub-version.')
|
|
218
301
|
.option('--hub-version <version>', 'Specify to install a specific version of Unity Hub. Cannot be used with --auto-update.')
|
|
@@ -221,7 +304,7 @@ program.command('hub-install')
|
|
|
221
304
|
if (options.verbose) {
|
|
222
305
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
223
306
|
}
|
|
224
|
-
logging_1.Logger.instance.
|
|
307
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
225
308
|
if (options.autoUpdate === true && options.hubVersion) {
|
|
226
309
|
logging_1.Logger.instance.error('Cannot use --auto-update with --hub-version.');
|
|
227
310
|
process.exit(1);
|
|
@@ -247,7 +330,7 @@ program.command('hub')
|
|
|
247
330
|
if (options.verbose) {
|
|
248
331
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
249
332
|
}
|
|
250
|
-
logging_1.Logger.instance.
|
|
333
|
+
logging_1.Logger.instance.debugOptions({ args, options });
|
|
251
334
|
const unityHub = new unity_hub_1.UnityHub();
|
|
252
335
|
const output = await unityHub.Exec(args, { silent: false, showCommand: logging_1.Logger.instance.logLevel === logging_1.LogLevel.DEBUG });
|
|
253
336
|
if (options.json) {
|
|
@@ -256,7 +339,7 @@ program.command('hub')
|
|
|
256
339
|
process.exit(0);
|
|
257
340
|
});
|
|
258
341
|
program.command('setup-unity')
|
|
259
|
-
.description('
|
|
342
|
+
.description('Find or install the Unity Editor for a project or specific version.')
|
|
260
343
|
.option('-p, --unity-project <unityProject>', 'The path to a Unity project or "none" to skip project detection.')
|
|
261
344
|
.option('-u, --unity-version <unityVersion>', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If specified, it will override the version read from the project.')
|
|
262
345
|
.option('-c, --changeset <changeset>', 'The Unity changeset to get (e.g. 1234567890ab).')
|
|
@@ -270,7 +353,7 @@ program.command('setup-unity')
|
|
|
270
353
|
if (options.verbose) {
|
|
271
354
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
272
355
|
}
|
|
273
|
-
logging_1.Logger.instance.
|
|
356
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
274
357
|
let unityProject;
|
|
275
358
|
if (options.unityProject) {
|
|
276
359
|
unityProject = await unity_project_1.UnityProject.GetProject(options.unityProject);
|
|
@@ -336,7 +419,7 @@ program.command('setup-unity')
|
|
|
336
419
|
process.exit(0);
|
|
337
420
|
});
|
|
338
421
|
program.command('uninstall-unity')
|
|
339
|
-
.description('Uninstall
|
|
422
|
+
.description('Uninstall a Unity Editor version.')
|
|
340
423
|
.option('-e, --unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version or the UNITY_EDITOR_PATH environment variable must be set.')
|
|
341
424
|
.option('-u, --unity-version <unityVersion>', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.')
|
|
342
425
|
.option('-c, --changeset <changeset>', 'The Unity changeset to get (e.g. 1234567890ab).')
|
|
@@ -346,7 +429,7 @@ program.command('uninstall-unity')
|
|
|
346
429
|
if (options.verbose) {
|
|
347
430
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
348
431
|
}
|
|
349
|
-
logging_1.Logger.instance.
|
|
432
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
350
433
|
let unityEditor;
|
|
351
434
|
const unityVersionStr = options.unityVersion?.toString()?.trim();
|
|
352
435
|
if (unityVersionStr) {
|
|
@@ -384,11 +467,11 @@ program.command('uninstall-unity')
|
|
|
384
467
|
});
|
|
385
468
|
program.commandsGroup('Unity Editor:');
|
|
386
469
|
program.command('run')
|
|
387
|
-
.description('Run command line args directly to the
|
|
470
|
+
.description('Run Unity Editor command line arguments (passes args directly to the editor).')
|
|
388
471
|
.option('--unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, --unity-project or the UNITY_EDITOR_PATH environment variable must be set.')
|
|
389
472
|
.option('--unity-project <unityProject>', 'The path to a Unity project. If unspecified, the UNITY_PROJECT_PATH environment variable will be used, otherwise no project will be specified.')
|
|
390
473
|
.option('--log-name <logName>', 'The name of the log file.')
|
|
391
|
-
.option('--log-level <logLevel>', '
|
|
474
|
+
.option('--log-level <logLevel>', 'Override the logger verbosity (debug, info, minimal, warning, error). Defaults to info.')
|
|
392
475
|
.option('--verbose', 'Enable verbose logging. Deprecated, use --log-level instead.')
|
|
393
476
|
.allowUnknownOption(true)
|
|
394
477
|
.argument('<args...>', 'Arguments to pass to the Unity Editor executable.')
|
|
@@ -436,7 +519,7 @@ program.command('run')
|
|
|
436
519
|
else if (requestedLogLevel) {
|
|
437
520
|
logging_1.Logger.instance.logLevel = requestedLogLevel;
|
|
438
521
|
}
|
|
439
|
-
logging_1.Logger.instance.
|
|
522
|
+
logging_1.Logger.instance.debugOptions({ options, args });
|
|
440
523
|
let unityEditor;
|
|
441
524
|
const editorPath = options.unityEditor?.toString()?.trim() || process.env.UNITY_EDITOR_PATH || undefined;
|
|
442
525
|
if (editorPath && editorPath.length > 0) {
|
|
@@ -487,19 +570,20 @@ program.command('run')
|
|
|
487
570
|
process.exit(0);
|
|
488
571
|
});
|
|
489
572
|
program.command('list-project-templates')
|
|
490
|
-
.description('List
|
|
573
|
+
.description('List available Unity project templates for an editor.')
|
|
491
574
|
.option('-u, --unity-version <unityVersion>', 'The Unity version to get (e.g. 2020.3.1f1, 2021.x, 2022.1.*, 6000). If unspecified, then --unity-editor must be specified.')
|
|
492
|
-
.option('-e, --unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, the UNITY_EDITOR_PATH environment variable must be set.')
|
|
575
|
+
.option('-e, --unity-editor <unityEditor>', 'The path to the Unity Editor executable. If unspecified, -u, --unity-version or the UNITY_EDITOR_PATH environment variable must be set.')
|
|
493
576
|
.option('--verbose', 'Enable verbose logging.')
|
|
494
577
|
.option('--json', 'Prints the last line of output as JSON string.')
|
|
495
578
|
.action(async (options) => {
|
|
496
579
|
if (options.verbose) {
|
|
497
580
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
498
581
|
}
|
|
499
|
-
logging_1.Logger.instance.
|
|
582
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
500
583
|
const unityVersionStr = options.unityVersion?.toString()?.trim();
|
|
501
|
-
|
|
502
|
-
|
|
584
|
+
const editorFromEnv = process.env.UNITY_EDITOR_PATH?.trim();
|
|
585
|
+
if (!unityVersionStr && !options.unityEditor?.toString()?.trim() && !editorFromEnv) {
|
|
586
|
+
logging_1.Logger.instance.error('You must specify a Unity version or editor path with -u, --unity-version, -e, --unity-editor, or set UNITY_EDITOR_PATH.');
|
|
503
587
|
process.exit(1);
|
|
504
588
|
}
|
|
505
589
|
let unityEditor;
|
|
@@ -508,7 +592,7 @@ program.command('list-project-templates')
|
|
|
508
592
|
unityEditor = await new unity_hub_1.UnityHub().GetEditor(unityVersion);
|
|
509
593
|
}
|
|
510
594
|
else {
|
|
511
|
-
const editorPath = options.unityEditor?.toString()?.trim() ||
|
|
595
|
+
const editorPath = options.unityEditor?.toString()?.trim() || editorFromEnv;
|
|
512
596
|
if (!editorPath || editorPath.length === 0) {
|
|
513
597
|
throw new Error('The Unity Editor path was not specified. Use -e or --unity-editor to specify it, or set the UNITY_EDITOR_PATH environment variable.');
|
|
514
598
|
}
|
|
@@ -541,10 +625,11 @@ program.command('create-project')
|
|
|
541
625
|
if (options.verbose) {
|
|
542
626
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
543
627
|
}
|
|
544
|
-
logging_1.Logger.instance.
|
|
628
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
545
629
|
const unityVersionStr = options.unityVersion?.toString()?.trim();
|
|
546
|
-
|
|
547
|
-
|
|
630
|
+
const editorFromEnv = process.env.UNITY_EDITOR_PATH?.trim();
|
|
631
|
+
if (!unityVersionStr && !options.unityEditor?.toString()?.trim() && !editorFromEnv) {
|
|
632
|
+
logging_1.Logger.instance.error('You must specify a Unity version or editor path with -u, --unity-version, -e, --unity-editor, or set UNITY_EDITOR_PATH.');
|
|
548
633
|
process.exit(1);
|
|
549
634
|
}
|
|
550
635
|
let unityEditor;
|
|
@@ -553,7 +638,7 @@ program.command('create-project')
|
|
|
553
638
|
unityEditor = await new unity_hub_1.UnityHub().GetEditor(unityVersion);
|
|
554
639
|
}
|
|
555
640
|
else {
|
|
556
|
-
const editorPath = options.unityEditor?.toString()?.trim() ||
|
|
641
|
+
const editorPath = options.unityEditor?.toString()?.trim() || editorFromEnv;
|
|
557
642
|
if (!editorPath || editorPath.length === 0) {
|
|
558
643
|
logging_1.Logger.instance.error('The Unity Editor path was not specified. Use -e or --unity-editor to specify it, or set the UNITY_EDITOR_PATH environment variable.');
|
|
559
644
|
process.exit(1);
|
|
@@ -597,8 +682,10 @@ program.command('open-project')
|
|
|
597
682
|
if (options.verbose) {
|
|
598
683
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
599
684
|
}
|
|
600
|
-
logging_1.Logger.instance.
|
|
601
|
-
const projectPath = options.unityProject?.toString()?.trim() ||
|
|
685
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
686
|
+
const projectPath = options.unityProject?.toString()?.trim() ||
|
|
687
|
+
process.env.UNITY_PROJECT_PATH ||
|
|
688
|
+
undefined;
|
|
602
689
|
const unityProject = await unity_project_1.UnityProject.GetProject(projectPath);
|
|
603
690
|
if (!unityProject) {
|
|
604
691
|
logging_1.Logger.instance.error(`The specified path is not a valid Unity project: ${projectPath}`);
|
|
@@ -638,19 +725,155 @@ program.command('editor-logs')
|
|
|
638
725
|
process.exit(0);
|
|
639
726
|
});
|
|
640
727
|
program.commandsGroup("Unity Package Manager:");
|
|
728
|
+
program.command('upm-install')
|
|
729
|
+
.description('Download and install the Unity Package Manager cli (pack/sign).')
|
|
730
|
+
.option('--verbose', 'Enable verbose logging.')
|
|
731
|
+
.option('--auto-update', 'Automatically updates the upm cli if it is already installed and a newer release is available. Cannot be used with --version.')
|
|
732
|
+
.option('--version <version>', 'Specify to install a specific version of the Unity Package Manager cli. Cannot be used with --auto-update.')
|
|
733
|
+
.option('--json', 'Print version and managed paths as JSON.')
|
|
734
|
+
.action(async (options) => {
|
|
735
|
+
if (options.verbose) {
|
|
736
|
+
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
737
|
+
}
|
|
738
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
739
|
+
try {
|
|
740
|
+
if (options.autoUpdate === true && options.version) {
|
|
741
|
+
logging_1.Logger.instance.error('Cannot use --auto-update with --version.');
|
|
742
|
+
process.exit(1);
|
|
743
|
+
}
|
|
744
|
+
const upm = new upm_cli_1.UpmCli();
|
|
745
|
+
let requestedVersion = options.version?.toString()?.trim();
|
|
746
|
+
if (options.autoUpdate === true) {
|
|
747
|
+
const currentVersion = upm.GetInstalledReleaseTag();
|
|
748
|
+
const latestVersion = await upm.GetLatestReleaseTag();
|
|
749
|
+
if (currentVersion && !upm.IsUpdateAvailable(latestVersion)) {
|
|
750
|
+
logging_1.Logger.instance.info(`Upm cli is already up to date (${currentVersion}).`);
|
|
751
|
+
requestedVersion = currentVersion;
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
if (currentVersion) {
|
|
755
|
+
logging_1.Logger.instance.info(`Updating upm cli ${currentVersion} -> ${latestVersion}...`);
|
|
756
|
+
}
|
|
757
|
+
requestedVersion = latestVersion;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
const ver = await upm.Install({
|
|
761
|
+
version: requestedVersion,
|
|
762
|
+
skipIfInstalled: true
|
|
763
|
+
});
|
|
764
|
+
await upm.Version(ver);
|
|
765
|
+
const exe = upm.executable;
|
|
766
|
+
if (options.json) {
|
|
767
|
+
process.stdout.write(`\n${JSON.stringify({
|
|
768
|
+
UPM_VERSION: ver,
|
|
769
|
+
UPM_CLI_PATH: exe,
|
|
770
|
+
UPM_MANAGED_ROOT: upm.managedRoot,
|
|
771
|
+
})}\n`);
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
process.stdout.write(`Upm cli ${ver} installed.\n`);
|
|
775
|
+
process.stdout.write(`${exe}\n`);
|
|
776
|
+
}
|
|
777
|
+
process.exit(0);
|
|
778
|
+
}
|
|
779
|
+
catch (error) {
|
|
780
|
+
logging_1.Logger.instance.error(`${error}`);
|
|
781
|
+
process.exit(1);
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
program.command('upm-version')
|
|
785
|
+
.description('Print the Unity Package Manager cli version.')
|
|
786
|
+
.action(async () => {
|
|
787
|
+
try {
|
|
788
|
+
const upmCli = new upm_cli_1.UpmCli();
|
|
789
|
+
const version = await upmCli.Version();
|
|
790
|
+
process.stdout.write(`v${version.version}\n`);
|
|
791
|
+
process.exit(0);
|
|
792
|
+
}
|
|
793
|
+
catch (error) {
|
|
794
|
+
logging_1.Logger.instance.error(`${error}`);
|
|
795
|
+
process.exit(1);
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
program.command('upm-pack')
|
|
799
|
+
.description('Sign and pack a Unity package.')
|
|
800
|
+
.option('--source <path>', 'An absolute or relative path to the root folder of the custom package to pack. This is the folder that contains the package manifest file (package.json). (optional; defaults to the current working directory).')
|
|
801
|
+
.option('--destination <path>', 'The output path for the signed tarball. If you specify a folder that doesn\'t exist, it will be created for you. Note: If you omit this parameter, the tarball will be placed in the current working directory.')
|
|
802
|
+
.option('--verbose', 'Enable verbose logging.')
|
|
803
|
+
.action(async (options) => {
|
|
804
|
+
if (options.verbose) {
|
|
805
|
+
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
806
|
+
}
|
|
807
|
+
logging_1.Logger.instance.debugOptions({ options });
|
|
808
|
+
try {
|
|
809
|
+
const upm = new upm_cli_1.UpmCli();
|
|
810
|
+
await upm.PromptInstallOrUpdateWhenInteractive();
|
|
811
|
+
let serviceAccountKeyId = process.env.UPM_SERVICE_ACCOUNT_KEY_ID?.trim();
|
|
812
|
+
if (!serviceAccountKeyId) {
|
|
813
|
+
serviceAccountKeyId = (await (0, utilities_1.PromptForSecretInput)('UPM_SERVICE_ACCOUNT_KEY_ID: ')).trim();
|
|
814
|
+
}
|
|
815
|
+
if (!serviceAccountKeyId) {
|
|
816
|
+
logging_1.Logger.instance.error('UPM_SERVICE_ACCOUNT_KEY_ID is required. Set the environment variable or enter a value when prompted.');
|
|
817
|
+
process.exit(1);
|
|
818
|
+
}
|
|
819
|
+
let serviceAccountKeySecret = process.env.UPM_SERVICE_ACCOUNT_KEY_SECRET?.trim();
|
|
820
|
+
if (!serviceAccountKeySecret) {
|
|
821
|
+
serviceAccountKeySecret = (await (0, utilities_1.PromptForSecretInput)('UPM_SERVICE_ACCOUNT_KEY_SECRET: ')).trim();
|
|
822
|
+
}
|
|
823
|
+
if (!serviceAccountKeySecret) {
|
|
824
|
+
logging_1.Logger.instance.error('UPM_SERVICE_ACCOUNT_KEY_SECRET is required. Set the environment variable or enter a value when prompted.');
|
|
825
|
+
process.exit(1);
|
|
826
|
+
}
|
|
827
|
+
process.env.UPM_SERVICE_ACCOUNT_KEY_ID = serviceAccountKeyId;
|
|
828
|
+
logging_1.Logger.instance.maskCredential(serviceAccountKeyId);
|
|
829
|
+
process.env.UPM_SERVICE_ACCOUNT_KEY_SECRET = serviceAccountKeySecret;
|
|
830
|
+
logging_1.Logger.instance.maskCredential(serviceAccountKeySecret);
|
|
831
|
+
let orgId = process.env.UNITY_ORGANIZATION_ID?.trim() || process.env.UNITY_ORG_ID?.trim();
|
|
832
|
+
const dest = options.destination?.toString()?.trim();
|
|
833
|
+
if (!orgId) {
|
|
834
|
+
orgId = (await (0, utilities_1.PromptForSecretInput)('UNITY_ORGANIZATION_ID: ')).trim();
|
|
835
|
+
}
|
|
836
|
+
if (!orgId) {
|
|
837
|
+
logging_1.Logger.instance.error('Organization ID is required. Set UNITY_ORGANIZATION_ID or UNITY_ORG_ID, or enter a value when prompted.');
|
|
838
|
+
process.exit(1);
|
|
839
|
+
}
|
|
840
|
+
logging_1.Logger.instance.maskCredential(orgId);
|
|
841
|
+
const redactLiterals = [orgId, serviceAccountKeyId, serviceAccountKeySecret].filter((s) => typeof s === 'string' && s.trim().length > 0);
|
|
842
|
+
const packOptions = {
|
|
843
|
+
organizationId: orgId,
|
|
844
|
+
};
|
|
845
|
+
if (dest) {
|
|
846
|
+
packOptions.destination = dest;
|
|
847
|
+
}
|
|
848
|
+
const sourceArg = options.source?.toString()?.trim();
|
|
849
|
+
packOptions.packageDirectory =
|
|
850
|
+
sourceArg && sourceArg.length > 0 ? path.resolve(sourceArg) : process.cwd();
|
|
851
|
+
await upm.Pack(packOptions, {
|
|
852
|
+
silent: false,
|
|
853
|
+
showCommand: logging_1.Logger.instance.logLevel === logging_1.LogLevel.DEBUG,
|
|
854
|
+
redactLiterals,
|
|
855
|
+
});
|
|
856
|
+
process.exit(0);
|
|
857
|
+
}
|
|
858
|
+
catch (error) {
|
|
859
|
+
logging_1.Logger.instance.error(`${error}`);
|
|
860
|
+
process.exit(1);
|
|
861
|
+
}
|
|
862
|
+
});
|
|
641
863
|
program.command('sign-package')
|
|
642
|
-
.description('Sign a Unity package.')
|
|
643
|
-
.option('--package <package>', 'Required. The fully qualified path to the folder that contains the package.json file for the package you want to sign. Note: Don
|
|
864
|
+
.description('[Deprecated] Sign a Unity package using Unity Editor 6000.3+ batch mode (-upmPack). Use unity-cli upm-pack with organization and service account credentials for new workflows.')
|
|
865
|
+
.option('--package <package>', 'Required. The fully qualified path to the folder that contains the package.json file for the package you want to sign. Note: Don\'t include package.json in this parameter value.')
|
|
644
866
|
.option('--output <output>', 'Optional. The output directory where you want to save the signed tarball file (.tgz). If unspecified, the package contents will be updated in place with the signed .attestation.p7m file.')
|
|
645
867
|
.option('--email <email>', 'Email associated with the Unity account. If unspecified, the UNITY_USERNAME environment variable will be used.')
|
|
646
868
|
.option('--password <password>', 'The password of the Unity account. If unspecified, the UNITY_PASSWORD environment variable will be used.')
|
|
647
869
|
.option('--organization <organization>', 'The Organization ID you copied from the Unity Cloud Dashboard. If unspecified, the UNITY_ORGANIZATION_ID environment variable will be used.')
|
|
648
870
|
.option('--verbose', 'Enable verbose logging.')
|
|
649
871
|
.action(async (options) => {
|
|
872
|
+
logging_1.Logger.instance.warn('The sign-package command is deprecated. Use unity-cli upm-pack --source <path-to-package-folder> --destination <output-path> with UNITY_ORGANIZATION_ID or UNITY_ORG_ID, UPM_SERVICE_ACCOUNT_KEY_ID, and UPM_SERVICE_ACCOUNT_KEY_SECRET (or secure prompts).');
|
|
650
873
|
if (options.verbose) {
|
|
651
874
|
logging_1.Logger.instance.logLevel = logging_1.LogLevel.DEBUG;
|
|
652
875
|
}
|
|
653
|
-
logging_1.Logger.instance.
|
|
876
|
+
logging_1.Logger.instance.debugOptions(options);
|
|
654
877
|
const packagePath = path.normalize(options.package?.toString()?.trim());
|
|
655
878
|
if (!packagePath || packagePath.length === 0) {
|
|
656
879
|
logging_1.Logger.instance.error('The package path is required. Use --package to specify it.');
|
|
@@ -700,6 +923,10 @@ program.command('sign-package')
|
|
|
700
923
|
logging_1.Logger.instance.error('The organization ID is required. Use --organization to specify it.');
|
|
701
924
|
process.exit(1);
|
|
702
925
|
}
|
|
926
|
+
// Mask credentials in CI environments before any potential logging
|
|
927
|
+
logging_1.Logger.instance.maskCredential(username);
|
|
928
|
+
logging_1.Logger.instance.maskCredential(password);
|
|
929
|
+
logging_1.Logger.instance.maskCredential(organization);
|
|
703
930
|
// must use a unity editor 6000.3 or newer
|
|
704
931
|
const unityVersion = new unity_version_1.UnityVersion('6000.3');
|
|
705
932
|
const unityHub = new unity_hub_1.UnityHub();
|
|
@@ -741,5 +968,8 @@ program.command('sign-package')
|
|
|
741
968
|
}
|
|
742
969
|
}
|
|
743
970
|
});
|
|
744
|
-
program.
|
|
971
|
+
void program.parseAsync(process.argv).catch((err) => {
|
|
972
|
+
logging_1.Logger.instance.error(err instanceof Error ? err.message : String(err));
|
|
973
|
+
process.exit(1);
|
|
974
|
+
});
|
|
745
975
|
//# sourceMappingURL=cli.js.map
|