@fgv/ts-res-cli 5.0.0-22 → 5.0.0-24

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/src/cli.ts DELETED
@@ -1,695 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Erik Fortune
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in all
12
- * copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- * SOFTWARE.
21
- */
22
-
23
- import { Command } from 'commander';
24
- import { Result, succeed, fail } from '@fgv/ts-utils';
25
- import { ICompileOptions, OutputFormat } from './options';
26
- import * as TsRes from '@fgv/ts-res';
27
-
28
- /**
29
- * Command-line options for the compile command
30
- */
31
- interface ICompileCommandOptions {
32
- input: string;
33
- output: string;
34
- config?: string;
35
- context?: string;
36
- contextFilter?: string;
37
- qualifierDefaults?: string;
38
- format: string;
39
- debug?: boolean;
40
- verbose?: boolean;
41
- quiet?: boolean;
42
- validate?: boolean;
43
- includeMetadata?: boolean;
44
- resourceTypes?: string;
45
- maxDistance?: number;
46
- reduceQualifiers?: boolean;
47
- }
48
-
49
- /**
50
- * Command-line options for the validate command
51
- */
52
- interface IValidateCommandOptions {
53
- input: string;
54
- config?: string;
55
- context?: string;
56
- contextFilter?: string;
57
- qualifierDefaults?: string;
58
- verbose?: boolean;
59
- quiet?: boolean;
60
- reduceQualifiers?: boolean;
61
- }
62
-
63
- /**
64
- * Command-line options for the info command
65
- */
66
- interface IInfoCommandOptions {
67
- input: string;
68
- config?: string;
69
- context?: string;
70
- contextFilter?: string;
71
- qualifierDefaults?: string;
72
- resourceTypes?: string;
73
- maxDistance?: number;
74
- reduceQualifiers?: boolean;
75
- }
76
-
77
- /**
78
- * Command-line options for the config command
79
- */
80
- interface IConfigCommandOptions {
81
- name?: string;
82
- output?: string;
83
- validate?: string;
84
- normalize?: string;
85
- qualifierDefaults?: string;
86
- list?: boolean;
87
- }
88
-
89
- /**
90
- * Command-line options for the archive command
91
- */
92
- interface IArchiveCommandOptions {
93
- input?: string;
94
- config?: string;
95
- output: string;
96
- verbose?: boolean;
97
- quiet?: boolean;
98
- }
99
-
100
- import { ResourceCompiler } from './compiler';
101
-
102
- /**
103
- * Main CLI class for ts-res-compile
104
- */
105
- export class TsResCliApp {
106
- private readonly _program: Command;
107
-
108
- public constructor() {
109
- this._program = new Command();
110
- this._setupCommands();
111
- }
112
-
113
- /**
114
- * Runs the CLI with the provided arguments
115
- */
116
- public async run(argv: string[]): Promise<void> {
117
- await this._program.parseAsync(argv);
118
- }
119
-
120
- /**
121
- * Sets up the CLI commands and options
122
- */
123
- private _setupCommands(): void {
124
- this._program
125
- .name('ts-res-compile')
126
- .description('Compile and optimize ts-res resources')
127
- .version('1.0.0');
128
-
129
- this._program
130
- .command('compile')
131
- .description('Compile resources from input to output format')
132
- .requiredOption('-i, --input <path>', 'Input file or directory path')
133
- .requiredOption('-o, --output <path>', 'Output file path')
134
- .option(
135
- '--config <name|path>',
136
- 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'
137
- )
138
- .option('-c, --context <json>', 'Context filter for resources (JSON string)')
139
- .option(
140
- '--context-filter <token>',
141
- 'Context filter token (pipe-separated, e.g., "language=en-US|territory=US")'
142
- )
143
- .option(
144
- '--qualifier-defaults <token>',
145
- 'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
146
- )
147
- .option('-f, --format <format>', 'Output format (compiled, source, js, ts, binary, bundle)', 'compiled')
148
- .option('--debug', 'Include debug information', false)
149
- .option('-v, --verbose', 'Verbose output', false)
150
- .option('-q, --quiet', 'Quiet output', false)
151
- .option('--validate', 'Validate resources during compilation', true)
152
- .option('--include-metadata', 'Include resource metadata in output', false)
153
- .option('--resource-types <types>', 'Resource type filter (comma-separated)')
154
- .option('--max-distance <number>', 'Maximum distance for language matching', parseInt)
155
- .option(
156
- '--reduce-qualifiers',
157
- 'Remove perfectly matching qualifier conditions from filtered resources',
158
- false
159
- )
160
- .action(async (options) => {
161
- await this._handleCompileCommand(options);
162
- });
163
-
164
- this._program
165
- .command('validate')
166
- .description('Validate resources without compilation')
167
- .requiredOption('-i, --input <path>', 'Input file or directory path')
168
- .option(
169
- '--config <name|path>',
170
- 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'
171
- )
172
- .option('-c, --context <json>', 'Context filter for resources (JSON string)')
173
- .option(
174
- '--context-filter <token>',
175
- 'Context filter token (pipe-separated, e.g., "language=en-US|territory=US")'
176
- )
177
- .option(
178
- '--qualifier-defaults <token>',
179
- 'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
180
- )
181
- .option('-v, --verbose', 'Verbose output', false)
182
- .option('-q, --quiet', 'Quiet output', false)
183
- .option(
184
- '--reduce-qualifiers',
185
- 'Remove perfectly matching qualifier conditions from filtered resources',
186
- false
187
- )
188
- .action(async (options) => {
189
- await this._handleValidateCommand(options);
190
- });
191
-
192
- this._program
193
- .command('info')
194
- .description('Show information about resources')
195
- .requiredOption('-i, --input <path>', 'Input file or directory path')
196
- .option(
197
- '--config <name|path>',
198
- 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'
199
- )
200
- .option('-c, --context <json>', 'Context filter for resources (JSON string)')
201
- .option(
202
- '--context-filter <token>',
203
- 'Context filter token (pipe-separated, e.g., "language=en-US|territory=US")'
204
- )
205
- .option(
206
- '--qualifier-defaults <token>',
207
- 'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
208
- )
209
- .option('--resource-types <types>', 'Resource type filter (comma-separated)')
210
- .option('--max-distance <number>', 'Maximum distance for language matching', parseInt)
211
- .option(
212
- '--reduce-qualifiers',
213
- 'Remove perfectly matching qualifier conditions from filtered resources',
214
- false
215
- )
216
- .action(async (options) => {
217
- await this._handleInfoCommand(options);
218
- });
219
-
220
- this._program
221
- .command('config')
222
- .description('Manage system configurations')
223
- .option('-n, --name <name>', 'Predefined configuration name to print')
224
- .option('-o, --output <path>', 'Output file path to save configuration')
225
- .option('--validate <path>', 'Validate a configuration file')
226
- .option('--normalize <path>', 'Normalize and validate a configuration file')
227
- .option(
228
- '--qualifier-defaults <token>',
229
- 'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
230
- )
231
- .option('-l, --list', 'List all available predefined configurations')
232
- .action(async (options) => {
233
- await this._handleConfigCommand(options);
234
- });
235
-
236
- this._program
237
- .command('archive')
238
- .description('Create ZIP archive of resources and configuration')
239
- .option('-i, --input <path>', 'Input file or directory path')
240
- .option('--config <path>', 'Configuration file path')
241
- .requiredOption('-o, --output <path>', 'Output ZIP file path')
242
- .option('-v, --verbose', 'Verbose output', false)
243
- .option('-q, --quiet', 'Quiet output', false)
244
- .action(async (options) => {
245
- await this._handleArchiveCommand(options);
246
- });
247
- }
248
-
249
- /**
250
- * Handles the compile command
251
- */
252
- private async _handleCompileCommand(options: ICompileCommandOptions): Promise<void> {
253
- const compileOptions = this._parseCompileOptions(options);
254
- if (compileOptions.isFailure()) {
255
- console.error(`Error: ${compileOptions.message}`);
256
- process.exit(1);
257
- }
258
-
259
- const compiler = new ResourceCompiler(compileOptions.value);
260
- const result = await compiler.compile();
261
-
262
- if (result.isFailure()) {
263
- console.error(`Error: ${result.message}`);
264
- process.exit(1);
265
- }
266
-
267
- if (!options.quiet && options.output) {
268
- console.log(`Successfully compiled resources to ${options.output}`);
269
- }
270
- }
271
-
272
- /**
273
- * Handles the validate command
274
- */
275
- private async _handleValidateCommand(options: IValidateCommandOptions): Promise<void> {
276
- // Convert JSON context to contextFilter if provided
277
- let contextFilter = options.contextFilter;
278
- if (options.context && !contextFilter) {
279
- try {
280
- const contextObj = JSON.parse(options.context);
281
- const tokens: string[] = [];
282
- for (const [key, value] of Object.entries(contextObj)) {
283
- tokens.push(`${key}=${value}`);
284
- }
285
- contextFilter = tokens.join('|');
286
- } catch (error) {
287
- console.error(`Error: Invalid context JSON: ${error}`);
288
- process.exit(1);
289
- }
290
- }
291
-
292
- const validateOptions: ICompileOptions = {
293
- input: options.input,
294
- output: '', // Not used for validation
295
- config: options.config,
296
- contextFilter,
297
- qualifierDefaults: options.qualifierDefaults,
298
- format: 'compiled',
299
- debug: false,
300
- verbose: options.verbose || false,
301
- quiet: options.quiet || false,
302
- validate: true,
303
- includeMetadata: false,
304
- reduceQualifiers: options.reduceQualifiers || false
305
- };
306
-
307
- const compiler = new ResourceCompiler(validateOptions);
308
- const result = await compiler.validate();
309
-
310
- if (result.isFailure()) {
311
- console.error(`Validation failed: ${result.message}`);
312
- process.exit(1);
313
- }
314
-
315
- if (!options.quiet) {
316
- console.log('Resources validated successfully');
317
- }
318
- }
319
-
320
- /**
321
- * Handles the info command
322
- */
323
- private async _handleInfoCommand(options: IInfoCommandOptions): Promise<void> {
324
- // Convert JSON context to contextFilter if provided
325
- let contextFilter = options.contextFilter;
326
- if (options.context && !contextFilter) {
327
- try {
328
- const contextObj = JSON.parse(options.context);
329
- const tokens: string[] = [];
330
- for (const [key, value] of Object.entries(contextObj)) {
331
- tokens.push(`${key}=${value}`);
332
- }
333
- contextFilter = tokens.join('|');
334
- } catch (error) {
335
- console.error(`Error: Invalid context JSON: ${error}`);
336
- process.exit(1);
337
- }
338
- }
339
-
340
- const infoOptions: ICompileOptions = {
341
- input: options.input,
342
- output: '', // Not used for info
343
- config: options.config,
344
- format: 'compiled',
345
- debug: false,
346
- verbose: false,
347
- quiet: false,
348
- validate: false,
349
- includeMetadata: true,
350
- contextFilter,
351
- qualifierDefaults: options.qualifierDefaults,
352
- resourceTypes: options.resourceTypes,
353
- maxDistance: options.maxDistance,
354
- reduceQualifiers: options.reduceQualifiers || false
355
- };
356
-
357
- const compiler = new ResourceCompiler(infoOptions);
358
- const result = await compiler.getInfo();
359
-
360
- if (result.isFailure()) {
361
- console.error(`Error: ${result.message}`);
362
- process.exit(1);
363
- }
364
-
365
- console.log(JSON.stringify(result.value, null, 2));
366
- }
367
-
368
- /**
369
- * Handles the config command
370
- */
371
- private async _handleConfigCommand(options: IConfigCommandOptions): Promise<void> {
372
- try {
373
- // List all predefined configurations
374
- if (options.list) {
375
- console.log('Available predefined configurations:');
376
- console.log('- default');
377
- console.log('- language-priority');
378
- console.log('- territory-priority');
379
- console.log('- extended-example');
380
- return;
381
- }
382
-
383
- // Print a specific predefined configuration
384
- if (options.name) {
385
- const predefinedNames: TsRes.Config.PredefinedSystemConfiguration[] = [
386
- 'default',
387
- 'language-priority',
388
- 'territory-priority',
389
- 'extended-example'
390
- ];
391
-
392
- if (!predefinedNames.includes(options.name as TsRes.Config.PredefinedSystemConfiguration)) {
393
- console.error(`Error: Predefined configuration '${options.name}' not found`);
394
- console.error(
395
- 'Available configurations: default, language-priority, territory-priority, extended-example'
396
- );
397
- process.exit(1);
398
- }
399
-
400
- const configResult = TsRes.Config.getPredefinedDeclaration(
401
- options.name as TsRes.Config.PredefinedSystemConfiguration
402
- );
403
- if (configResult.isFailure()) {
404
- console.error(
405
- `Error: Failed to load predefined configuration '${options.name}': ${configResult.message}`
406
- );
407
- process.exit(1);
408
- }
409
-
410
- let config = configResult.value;
411
-
412
- // Apply qualifier defaults if provided
413
- if (options.qualifierDefaults) {
414
- const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(config);
415
- if (tempSystemConfigResult.isFailure()) {
416
- console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);
417
- process.exit(1);
418
- }
419
-
420
- const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(
421
- tempSystemConfigResult.value.qualifiers
422
- );
423
- const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);
424
- if (defaultsResult.isFailure()) {
425
- console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);
426
- process.exit(1);
427
- }
428
-
429
- const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(
430
- config,
431
- defaultsResult.value
432
- );
433
- if (updatedConfigResult.isFailure()) {
434
- console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);
435
- process.exit(1);
436
- }
437
-
438
- config = updatedConfigResult.value;
439
- }
440
-
441
- const output = JSON.stringify(config, null, 2);
442
-
443
- if (options.output) {
444
- const fs = await import('fs').then((m) => m.promises);
445
- const path = await import('path');
446
- const outputPath = path.resolve(options.output);
447
- const outputDir = path.dirname(outputPath);
448
-
449
- await fs.mkdir(outputDir, { recursive: true });
450
- await fs.writeFile(outputPath, output, 'utf-8');
451
- console.log(`Configuration saved to: ${outputPath}`);
452
- } else {
453
- console.log(output);
454
- }
455
- return;
456
- }
457
-
458
- // Validate a configuration file
459
- if (options.validate) {
460
- const fs = await import('fs').then((m) => m.promises);
461
- const path = await import('path');
462
-
463
- const configPath = path.resolve(options.validate);
464
- const configContent = await fs.readFile(configPath, 'utf-8');
465
- const configData = JSON.parse(configContent);
466
-
467
- const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);
468
- if (configResult.isFailure()) {
469
- console.error(`Validation failed: ${configResult.message}`);
470
- process.exit(1);
471
- }
472
-
473
- console.log(`Configuration file '${configPath}' is valid`);
474
- return;
475
- }
476
-
477
- // Normalize a configuration file
478
- if (options.normalize) {
479
- const fs = await import('fs').then((m) => m.promises);
480
- const path = await import('path');
481
-
482
- const configPath = path.resolve(options.normalize);
483
- const configContent = await fs.readFile(configPath, 'utf-8');
484
- const configData = JSON.parse(configContent);
485
-
486
- const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);
487
- if (configResult.isFailure()) {
488
- console.error(`Normalization failed: ${configResult.message}`);
489
- process.exit(1);
490
- }
491
-
492
- let normalizedConfig = configResult.value;
493
-
494
- // Apply qualifier defaults if provided
495
- if (options.qualifierDefaults) {
496
- const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(normalizedConfig);
497
- if (tempSystemConfigResult.isFailure()) {
498
- console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);
499
- process.exit(1);
500
- }
501
-
502
- const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(
503
- tempSystemConfigResult.value.qualifiers
504
- );
505
- const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);
506
- if (defaultsResult.isFailure()) {
507
- console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);
508
- process.exit(1);
509
- }
510
-
511
- const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(
512
- normalizedConfig,
513
- defaultsResult.value
514
- );
515
- if (updatedConfigResult.isFailure()) {
516
- console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);
517
- process.exit(1);
518
- }
519
-
520
- normalizedConfig = updatedConfigResult.value;
521
- }
522
-
523
- const output = JSON.stringify(normalizedConfig, null, 2);
524
-
525
- if (options.output) {
526
- const outputPath = path.resolve(options.output);
527
- const outputDir = path.dirname(outputPath);
528
-
529
- await fs.mkdir(outputDir, { recursive: true });
530
- await fs.writeFile(outputPath, output, 'utf-8');
531
- console.log(`Normalized configuration saved to: ${outputPath}`);
532
- } else {
533
- console.log(output);
534
- }
535
- return;
536
- }
537
-
538
- // If no specific action, print default configuration
539
- const defaultResult = TsRes.Config.getPredefinedDeclaration('default');
540
- if (defaultResult.isFailure()) {
541
- console.error(`Error: Default configuration not available`);
542
- process.exit(1);
543
- }
544
-
545
- let defaultConfig = defaultResult.value;
546
-
547
- // Apply qualifier defaults if provided
548
- if (options.qualifierDefaults) {
549
- const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(defaultConfig);
550
- if (tempSystemConfigResult.isFailure()) {
551
- console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);
552
- process.exit(1);
553
- }
554
-
555
- const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(
556
- tempSystemConfigResult.value.qualifiers
557
- );
558
- const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);
559
- if (defaultsResult.isFailure()) {
560
- console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);
561
- process.exit(1);
562
- }
563
-
564
- const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(
565
- defaultConfig,
566
- defaultsResult.value
567
- );
568
- if (updatedConfigResult.isFailure()) {
569
- console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);
570
- process.exit(1);
571
- }
572
-
573
- defaultConfig = updatedConfigResult.value;
574
- }
575
-
576
- console.log(JSON.stringify(defaultConfig, null, 2));
577
- } catch (error) {
578
- console.error(`Error: ${error}`);
579
- process.exit(1);
580
- }
581
- }
582
-
583
- /**
584
- * Handles the archive command
585
- */
586
- private async _handleArchiveCommand(options: IArchiveCommandOptions): Promise<void> {
587
- try {
588
- // Import ZipArchive dynamically to avoid loading if not needed
589
- const { ZipArchive } = await import('@fgv/ts-res');
590
-
591
- if (!options.input && !options.config) {
592
- console.error('Error: At least one of --input or --config must be specified');
593
- process.exit(1);
594
- }
595
-
596
- if (!options.quiet) {
597
- console.log('Creating ZIP archive...');
598
- if (options.input) console.log(`Input: ${options.input}`);
599
- if (options.config) console.log(`Config: ${options.config}`);
600
- console.log(`Output: ${options.output}`);
601
- }
602
-
603
- // Create ZIP archive using the new zip-archive packlet
604
- const creator = new ZipArchive.ZipArchiveCreator();
605
- const createResult = await creator.createFromBuffer(
606
- {
607
- inputPath: options.input,
608
- configPath: options.config
609
- },
610
- options.verbose
611
- ? (phase, progress, message) => {
612
- console.log(`[${phase}] ${progress}% - ${message}`);
613
- }
614
- : undefined
615
- );
616
-
617
- if (createResult.isFailure()) {
618
- console.error(`Error: Failed to create ZIP archive: ${createResult.message}`);
619
- process.exit(1);
620
- }
621
-
622
- const { zipBuffer, manifest, size } = createResult.value;
623
-
624
- // Write the ZIP buffer to the specified output file
625
- const fs = await import('fs').then((m) => m.promises);
626
- const path = await import('path');
627
- const outputPath = path.resolve(options.output);
628
- const outputDir = path.dirname(outputPath);
629
-
630
- // Ensure output directory exists
631
- await fs.mkdir(outputDir, { recursive: true });
632
-
633
- // Write ZIP file
634
- await fs.writeFile(outputPath, zipBuffer);
635
-
636
- if (!options.quiet) {
637
- console.log(`ZIP archive created successfully: ${outputPath}`);
638
- console.log(`Archive size: ${(size / 1024).toFixed(2)} KB`);
639
- console.log(`Manifest:`);
640
- console.log(JSON.stringify(manifest, null, 2));
641
- }
642
- } catch (error) {
643
- console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
644
- process.exit(1);
645
- }
646
- }
647
-
648
- /**
649
- * Parses and validates compile options
650
- */
651
- private _parseCompileOptions(options: ICompileCommandOptions): Result<ICompileOptions> {
652
- try {
653
- const format = options.format as OutputFormat;
654
- if (!['compiled', 'source', 'js', 'ts', 'binary', 'bundle'].includes(format)) {
655
- return fail(`Invalid format: ${format}`);
656
- }
657
-
658
- // Convert JSON context to contextFilter if provided
659
- let contextFilter = options.contextFilter;
660
- if (options.context && !contextFilter) {
661
- try {
662
- const contextObj = JSON.parse(options.context);
663
- const tokens: string[] = [];
664
- for (const [key, value] of Object.entries(contextObj)) {
665
- tokens.push(`${key}=${value}`);
666
- }
667
- contextFilter = tokens.join('|');
668
- } catch (error) {
669
- return fail(`Invalid context JSON: ${error}`);
670
- }
671
- }
672
-
673
- const compileOptions: ICompileOptions = {
674
- input: options.input,
675
- output: options.output,
676
- config: options.config,
677
- contextFilter,
678
- qualifierDefaults: options.qualifierDefaults,
679
- format,
680
- debug: options.debug || false,
681
- verbose: options.verbose || false,
682
- quiet: options.quiet || false,
683
- validate: options.validate !== false,
684
- includeMetadata: options.includeMetadata || false,
685
- resourceTypes: options.resourceTypes,
686
- maxDistance: options.maxDistance,
687
- reduceQualifiers: options.reduceQualifiers || false
688
- };
689
-
690
- return succeed(compileOptions);
691
- } catch (error) {
692
- return fail(`Failed to parse options: ${error}`);
693
- }
694
- }
695
- }