@fgv/ts-res-browser-cli 5.0.0-3 → 5.0.0-31
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 +35 -11
- package/eslint.config.js +16 -0
- package/lib/cli.d.ts +0 -4
- package/lib/cli.js +8 -17
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/options.d.ts +16 -0
- package/lib/simpleBrowserLauncher.d.ts +32 -0
- package/lib/{browserLauncher.js → simpleBrowserLauncher.js} +53 -162
- package/lib/zipArchiver.d.ts +5 -17
- package/lib/zipArchiver.js +11 -72
- package/package.json +13 -13
- package/.rush/temp/6fdce6325ccacda5ae840a289f20e286e54e4f4b.tar.log +0 -32
- package/.rush/temp/chunked-rush-logs/ts-res-browser-cli.build.chunks.jsonl +0 -5
- package/.rush/temp/operation/build/all.log +0 -5
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -5
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -651
- package/config/rig.json +0 -16
- package/lib/browserLauncher.d.ts +0 -57
- package/lib/browserLauncher.d.ts.map +0 -1
- package/lib/browserLauncher.js.map +0 -1
- package/lib/cli.d.ts.map +0 -1
- package/lib/cli.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/options.d.ts.map +0 -1
- package/lib/options.js.map +0 -1
- package/lib/zipArchiver.d.ts.map +0 -1
- package/lib/zipArchiver.js.map +0 -1
- package/rush-logs/ts-res-browser-cli.build.cache.log +0 -3
- package/rush-logs/ts-res-browser-cli.build.log +0 -5
- package/src/browserLauncher.ts +0 -406
- package/src/cli.ts +0 -423
- package/src/index.ts +0 -26
- package/src/options.ts +0 -133
- package/src/zipArchiver.ts +0 -153
- package/tsconfig.json +0 -7
package/src/cli.ts
DELETED
|
@@ -1,423 +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 * as TsRes from '@fgv/ts-res';
|
|
26
|
-
import { promises as fs } from 'fs';
|
|
27
|
-
import * as path from 'path';
|
|
28
|
-
|
|
29
|
-
import { IBrowseOptions, IBrowseCommandOptions } from './options';
|
|
30
|
-
import { BrowserLauncher } from './browserLauncher';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Main CLI class for ts-res-browser-cli
|
|
34
|
-
*/
|
|
35
|
-
export class TsResBrowserCliApp {
|
|
36
|
-
private readonly _program: Command;
|
|
37
|
-
private readonly _launcher: BrowserLauncher;
|
|
38
|
-
|
|
39
|
-
public constructor() {
|
|
40
|
-
this._program = new Command();
|
|
41
|
-
this._launcher = new BrowserLauncher();
|
|
42
|
-
this._setupCommands();
|
|
43
|
-
this._setupGracefulShutdown();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Runs the CLI with the provided arguments
|
|
48
|
-
*/
|
|
49
|
-
public async run(argv: string[]): Promise<void> {
|
|
50
|
-
await this._program.parseAsync(argv);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Sets up the CLI commands and options
|
|
55
|
-
*/
|
|
56
|
-
private _setupCommands(): void {
|
|
57
|
-
this._program
|
|
58
|
-
.name('ts-res-browser-cli')
|
|
59
|
-
.description('Launch ts-res-browser with specified resources and configuration')
|
|
60
|
-
.version('1.0.0');
|
|
61
|
-
|
|
62
|
-
// Default behavior (no command) - launch with options or show help
|
|
63
|
-
this._program
|
|
64
|
-
.option('-i, --input <path>', 'Input file or directory path')
|
|
65
|
-
.option(
|
|
66
|
-
'--config <name|path>',
|
|
67
|
-
'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'
|
|
68
|
-
)
|
|
69
|
-
.option('-c, --context <json>', 'Context filter for resources (JSON string)')
|
|
70
|
-
.option(
|
|
71
|
-
'--context-filter <token>',
|
|
72
|
-
'Context filter token (pipe-separated, e.g., "language=en-US|territory=US")'
|
|
73
|
-
)
|
|
74
|
-
.option(
|
|
75
|
-
'--qualifier-defaults <token>',
|
|
76
|
-
'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
|
|
77
|
-
)
|
|
78
|
-
.option('--resource-types <types>', 'Resource type filter (comma-separated)')
|
|
79
|
-
.option('--max-distance <number>', 'Maximum distance for language matching', parseInt)
|
|
80
|
-
.option(
|
|
81
|
-
'--reduce-qualifiers',
|
|
82
|
-
'Remove perfectly matching qualifier conditions from filtered resources',
|
|
83
|
-
false
|
|
84
|
-
)
|
|
85
|
-
.option('-v, --verbose', 'Verbose output', false)
|
|
86
|
-
.option('-q, --quiet', 'Quiet output', false)
|
|
87
|
-
.option('-p, --port <number>', 'Port for local browser instance', parseInt)
|
|
88
|
-
.option('--url <url>', 'URL of remote browser instance')
|
|
89
|
-
.option('--no-open', 'Do not open browser automatically')
|
|
90
|
-
.option('--interactive', 'Launch in interactive mode with sample data', false)
|
|
91
|
-
.option('--dev', 'Automatically start development server locally', false)
|
|
92
|
-
.action(async (options) => {
|
|
93
|
-
// If no options provided, show help
|
|
94
|
-
if (!this._hasOptions(options)) {
|
|
95
|
-
this._program.help();
|
|
96
|
-
} else {
|
|
97
|
-
await this._handleBrowseCommand(options);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// Browse command (explicit)
|
|
102
|
-
this._program
|
|
103
|
-
.command('browse')
|
|
104
|
-
.description('Launch browser with specified resources and configuration')
|
|
105
|
-
.option('-i, --input <path>', 'Input file or directory path')
|
|
106
|
-
.option(
|
|
107
|
-
'--config <name|path>',
|
|
108
|
-
'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'
|
|
109
|
-
)
|
|
110
|
-
.option('-c, --context <json>', 'Context filter for resources (JSON string)')
|
|
111
|
-
.option(
|
|
112
|
-
'--context-filter <token>',
|
|
113
|
-
'Context filter token (pipe-separated, e.g., "language=en-US|territory=US")'
|
|
114
|
-
)
|
|
115
|
-
.option(
|
|
116
|
-
'--qualifier-defaults <token>',
|
|
117
|
-
'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
|
|
118
|
-
)
|
|
119
|
-
.option('--resource-types <types>', 'Resource type filter (comma-separated)')
|
|
120
|
-
.option('--max-distance <number>', 'Maximum distance for language matching', parseInt)
|
|
121
|
-
.option(
|
|
122
|
-
'--reduce-qualifiers',
|
|
123
|
-
'Remove perfectly matching qualifier conditions from filtered resources',
|
|
124
|
-
false
|
|
125
|
-
)
|
|
126
|
-
.option('-v, --verbose', 'Verbose output', false)
|
|
127
|
-
.option('-q, --quiet', 'Quiet output', false)
|
|
128
|
-
.option('-p, --port <number>', 'Port for local browser instance', parseInt)
|
|
129
|
-
.option('--url <url>', 'URL of remote browser instance')
|
|
130
|
-
.option('--no-open', 'Do not open browser automatically')
|
|
131
|
-
.option('--interactive', 'Launch in interactive mode with sample data', false)
|
|
132
|
-
.option('--dev', 'Automatically start development server locally', false)
|
|
133
|
-
.action(async (options) => {
|
|
134
|
-
await this._handleBrowseCommand(options);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// Config command (similar to ts-res-cli)
|
|
138
|
-
this._program
|
|
139
|
-
.command('config')
|
|
140
|
-
.description('Manage system configurations')
|
|
141
|
-
.option('-n, --name <name>', 'Predefined configuration name to print')
|
|
142
|
-
.option('-o, --output <path>', 'Output file path to save configuration')
|
|
143
|
-
.option('--validate <path>', 'Validate a configuration file')
|
|
144
|
-
.option('--normalize <path>', 'Normalize and validate a configuration file')
|
|
145
|
-
.option(
|
|
146
|
-
'--qualifier-defaults <token>',
|
|
147
|
-
'Qualifier default values token (pipe-separated, e.g., "language=en-US,en-CA|territory=US")'
|
|
148
|
-
)
|
|
149
|
-
.option('-l, --list', 'List all available predefined configurations')
|
|
150
|
-
.action(async (options) => {
|
|
151
|
-
await this._handleConfigCommand(options);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Check if any meaningful options were provided
|
|
157
|
-
*/
|
|
158
|
-
private _hasOptions(options: IBrowseCommandOptions): boolean {
|
|
159
|
-
return !!(
|
|
160
|
-
options.input ||
|
|
161
|
-
options.config ||
|
|
162
|
-
options.context ||
|
|
163
|
-
options.contextFilter ||
|
|
164
|
-
options.qualifierDefaults ||
|
|
165
|
-
options.resourceTypes ||
|
|
166
|
-
options.maxDistance !== undefined ||
|
|
167
|
-
options.reduceQualifiers ||
|
|
168
|
-
options.interactive ||
|
|
169
|
-
options.url ||
|
|
170
|
-
options.dev
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Handles the browse command
|
|
176
|
-
*/
|
|
177
|
-
private async _handleBrowseCommand(options: IBrowseCommandOptions): Promise<void> {
|
|
178
|
-
const browseOptions = this._parseBrowseOptions(options);
|
|
179
|
-
if (browseOptions.isFailure()) {
|
|
180
|
-
console.error(`Error: ${browseOptions.message}`);
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const result = await this._launcher.launch(browseOptions.value);
|
|
185
|
-
if (result.isFailure()) {
|
|
186
|
-
console.error(`Error: ${result.message}`);
|
|
187
|
-
process.exit(1);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Handles the config command (similar to ts-res-cli)
|
|
193
|
-
*/
|
|
194
|
-
private async _handleConfigCommand(options: any): Promise<void> {
|
|
195
|
-
try {
|
|
196
|
-
// List all predefined configurations
|
|
197
|
-
if (options.list) {
|
|
198
|
-
console.log('Available predefined configurations:');
|
|
199
|
-
console.log('- default');
|
|
200
|
-
console.log('- language-priority');
|
|
201
|
-
console.log('- territory-priority');
|
|
202
|
-
console.log('- extended-example');
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Print a specific predefined configuration
|
|
207
|
-
if (options.name) {
|
|
208
|
-
const predefinedNames: TsRes.Config.PredefinedSystemConfiguration[] = [
|
|
209
|
-
'default',
|
|
210
|
-
'language-priority',
|
|
211
|
-
'territory-priority',
|
|
212
|
-
'extended-example'
|
|
213
|
-
];
|
|
214
|
-
|
|
215
|
-
if (!predefinedNames.includes(options.name as TsRes.Config.PredefinedSystemConfiguration)) {
|
|
216
|
-
console.error(`Error: Predefined configuration '${options.name}' not found`);
|
|
217
|
-
console.error(
|
|
218
|
-
'Available configurations: default, language-priority, territory-priority, extended-example'
|
|
219
|
-
);
|
|
220
|
-
process.exit(1);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const configResult = TsRes.Config.getPredefinedDeclaration(
|
|
224
|
-
options.name as TsRes.Config.PredefinedSystemConfiguration
|
|
225
|
-
);
|
|
226
|
-
if (configResult.isFailure()) {
|
|
227
|
-
console.error(
|
|
228
|
-
`Error: Failed to load predefined configuration '${options.name}': ${configResult.message}`
|
|
229
|
-
);
|
|
230
|
-
process.exit(1);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
let config = configResult.value;
|
|
234
|
-
|
|
235
|
-
// Apply qualifier defaults if provided
|
|
236
|
-
if (options.qualifierDefaults) {
|
|
237
|
-
const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(config);
|
|
238
|
-
if (tempSystemConfigResult.isFailure()) {
|
|
239
|
-
console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);
|
|
240
|
-
process.exit(1);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(
|
|
244
|
-
tempSystemConfigResult.value.qualifiers
|
|
245
|
-
);
|
|
246
|
-
const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);
|
|
247
|
-
if (defaultsResult.isFailure()) {
|
|
248
|
-
console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(
|
|
253
|
-
config,
|
|
254
|
-
defaultsResult.value
|
|
255
|
-
);
|
|
256
|
-
if (updatedConfigResult.isFailure()) {
|
|
257
|
-
console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);
|
|
258
|
-
process.exit(1);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
config = updatedConfigResult.value;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const output = JSON.stringify(config, null, 2);
|
|
265
|
-
|
|
266
|
-
if (options.output) {
|
|
267
|
-
const outputPath = path.resolve(options.output);
|
|
268
|
-
const outputDir = path.dirname(outputPath);
|
|
269
|
-
|
|
270
|
-
await fs.mkdir(outputDir, { recursive: true });
|
|
271
|
-
await fs.writeFile(outputPath, output, 'utf-8');
|
|
272
|
-
console.log(`Configuration saved to: ${outputPath}`);
|
|
273
|
-
} else {
|
|
274
|
-
console.log(output);
|
|
275
|
-
}
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Validate a configuration file
|
|
280
|
-
if (options.validate) {
|
|
281
|
-
const configPath = path.resolve(options.validate);
|
|
282
|
-
const configContent = await fs.readFile(configPath, 'utf-8');
|
|
283
|
-
const configData = JSON.parse(configContent);
|
|
284
|
-
|
|
285
|
-
const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);
|
|
286
|
-
if (configResult.isFailure()) {
|
|
287
|
-
console.error(`Validation failed: ${configResult.message}`);
|
|
288
|
-
process.exit(1);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
console.log(`Configuration file '${configPath}' is valid`);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Normalize a configuration file
|
|
296
|
-
if (options.normalize) {
|
|
297
|
-
const configPath = path.resolve(options.normalize);
|
|
298
|
-
const configContent = await fs.readFile(configPath, 'utf-8');
|
|
299
|
-
const configData = JSON.parse(configContent);
|
|
300
|
-
|
|
301
|
-
const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);
|
|
302
|
-
if (configResult.isFailure()) {
|
|
303
|
-
console.error(`Normalization failed: ${configResult.message}`);
|
|
304
|
-
process.exit(1);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
let normalizedConfig = configResult.value;
|
|
308
|
-
|
|
309
|
-
// Apply qualifier defaults if provided
|
|
310
|
-
if (options.qualifierDefaults) {
|
|
311
|
-
const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(normalizedConfig);
|
|
312
|
-
if (tempSystemConfigResult.isFailure()) {
|
|
313
|
-
console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);
|
|
314
|
-
process.exit(1);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(
|
|
318
|
-
tempSystemConfigResult.value.qualifiers
|
|
319
|
-
);
|
|
320
|
-
const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);
|
|
321
|
-
if (defaultsResult.isFailure()) {
|
|
322
|
-
console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);
|
|
323
|
-
process.exit(1);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(
|
|
327
|
-
normalizedConfig,
|
|
328
|
-
defaultsResult.value
|
|
329
|
-
);
|
|
330
|
-
if (updatedConfigResult.isFailure()) {
|
|
331
|
-
console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);
|
|
332
|
-
process.exit(1);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
normalizedConfig = updatedConfigResult.value;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const output = JSON.stringify(normalizedConfig, null, 2);
|
|
339
|
-
|
|
340
|
-
if (options.output) {
|
|
341
|
-
const outputPath = path.resolve(options.output);
|
|
342
|
-
const outputDir = path.dirname(outputPath);
|
|
343
|
-
|
|
344
|
-
await fs.mkdir(outputDir, { recursive: true });
|
|
345
|
-
await fs.writeFile(outputPath, output, 'utf-8');
|
|
346
|
-
console.log(`Normalized configuration saved to: ${outputPath}`);
|
|
347
|
-
} else {
|
|
348
|
-
console.log(output);
|
|
349
|
-
}
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// If no specific action, print default configuration
|
|
354
|
-
const defaultResult = TsRes.Config.getPredefinedDeclaration('default');
|
|
355
|
-
if (defaultResult.isFailure()) {
|
|
356
|
-
console.error(`Error: Default configuration not available`);
|
|
357
|
-
process.exit(1);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
console.log(JSON.stringify(defaultResult.value, null, 2));
|
|
361
|
-
} catch (error) {
|
|
362
|
-
console.error(`Error: ${error}`);
|
|
363
|
-
process.exit(1);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Parses and validates browse options
|
|
369
|
-
*/
|
|
370
|
-
private _parseBrowseOptions(options: IBrowseCommandOptions): Result<IBrowseOptions> {
|
|
371
|
-
try {
|
|
372
|
-
// Convert JSON context to contextFilter if provided
|
|
373
|
-
let contextFilter = options.contextFilter;
|
|
374
|
-
if (options.context && !contextFilter) {
|
|
375
|
-
try {
|
|
376
|
-
const contextObj = JSON.parse(options.context);
|
|
377
|
-
const tokens: string[] = [];
|
|
378
|
-
for (const [key, value] of Object.entries(contextObj)) {
|
|
379
|
-
tokens.push(`${key}=${value}`);
|
|
380
|
-
}
|
|
381
|
-
contextFilter = tokens.join('|');
|
|
382
|
-
} catch (error) {
|
|
383
|
-
return fail(`Invalid context JSON: ${error}`);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
const browseOptions: IBrowseOptions = {
|
|
388
|
-
input: options.input,
|
|
389
|
-
config: options.config,
|
|
390
|
-
contextFilter,
|
|
391
|
-
qualifierDefaults: options.qualifierDefaults,
|
|
392
|
-
resourceTypes: options.resourceTypes,
|
|
393
|
-
maxDistance: options.maxDistance,
|
|
394
|
-
reduceQualifiers: options.reduceQualifiers || false,
|
|
395
|
-
verbose: options.verbose || false,
|
|
396
|
-
quiet: options.quiet || false,
|
|
397
|
-
port: options.port,
|
|
398
|
-
url: options.url,
|
|
399
|
-
open: options.open,
|
|
400
|
-
interactive: options.interactive || false,
|
|
401
|
-
dev: options.dev || false
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
return succeed(browseOptions);
|
|
405
|
-
} catch (error) {
|
|
406
|
-
return fail(`Failed to parse options: ${error}`);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Sets up graceful shutdown handling
|
|
412
|
-
*/
|
|
413
|
-
private _setupGracefulShutdown(): void {
|
|
414
|
-
const shutdown = (signal: string) => {
|
|
415
|
-
console.log(`\nReceived ${signal}, shutting down gracefully...`);
|
|
416
|
-
this._launcher.shutdown();
|
|
417
|
-
process.exit(0);
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
421
|
-
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
422
|
-
}
|
|
423
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,26 +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
|
-
// Export main components
|
|
24
|
-
export * from './cli';
|
|
25
|
-
export * from './options';
|
|
26
|
-
export * from './browserLauncher';
|
package/src/options.ts
DELETED
|
@@ -1,133 +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
|
-
/**
|
|
24
|
-
* Options for launching the ts-res browser
|
|
25
|
-
*/
|
|
26
|
-
export interface IBrowseOptions {
|
|
27
|
-
/**
|
|
28
|
-
* Input file or directory path
|
|
29
|
-
*/
|
|
30
|
-
input?: string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* System configuration file path (JSON file in ISystemConfiguration format)
|
|
34
|
-
* or predefined configuration name
|
|
35
|
-
*/
|
|
36
|
-
config?: string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Context filter token (pipe-separated qualifier=value pairs, e.g., 'language=en-US|territory=US')
|
|
40
|
-
*/
|
|
41
|
-
contextFilter?: string;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Qualifier default values token (pipe-separated qualifier=value pairs, e.g., 'language=en-US,en-CA|territory=US')
|
|
45
|
-
*/
|
|
46
|
-
qualifierDefaults?: string;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Resource types filter (comma-separated, e.g., 'json,string')
|
|
50
|
-
*/
|
|
51
|
-
resourceTypes?: string;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Maximum distance for language matching
|
|
55
|
-
*/
|
|
56
|
-
maxDistance?: number;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Whether to reduce qualifiers when filtering by context
|
|
60
|
-
*/
|
|
61
|
-
reduceQualifiers?: boolean;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Whether to run in verbose mode
|
|
65
|
-
*/
|
|
66
|
-
verbose?: boolean;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Whether to run in quiet mode
|
|
70
|
-
*/
|
|
71
|
-
quiet?: boolean;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Port to run the development server on (for launching locally)
|
|
75
|
-
*/
|
|
76
|
-
port?: number;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Whether to open the browser automatically
|
|
80
|
-
*/
|
|
81
|
-
open?: boolean;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Whether to launch in interactive mode (with sample data)
|
|
85
|
-
*/
|
|
86
|
-
interactive?: boolean;
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Browser URL to launch (for remote instances)
|
|
90
|
-
*/
|
|
91
|
-
url?: string;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Whether to automatically start the development server
|
|
95
|
-
*/
|
|
96
|
-
dev?: boolean;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Whether to use ZIP loading mode (internal flag)
|
|
100
|
-
*/
|
|
101
|
-
loadZip?: boolean;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Path to ZIP file to load (internal flag)
|
|
105
|
-
*/
|
|
106
|
-
zipPath?: string;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Name of ZIP file to load (internal flag)
|
|
110
|
-
*/
|
|
111
|
-
zipFile?: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Command-line options for the browse command
|
|
116
|
-
*/
|
|
117
|
-
export interface IBrowseCommandOptions {
|
|
118
|
-
input?: string;
|
|
119
|
-
config?: string;
|
|
120
|
-
context?: string;
|
|
121
|
-
contextFilter?: string;
|
|
122
|
-
qualifierDefaults?: string;
|
|
123
|
-
resourceTypes?: string;
|
|
124
|
-
maxDistance?: number;
|
|
125
|
-
reduceQualifiers?: boolean;
|
|
126
|
-
verbose?: boolean;
|
|
127
|
-
quiet?: boolean;
|
|
128
|
-
port?: number;
|
|
129
|
-
open?: boolean;
|
|
130
|
-
interactive?: boolean;
|
|
131
|
-
url?: string;
|
|
132
|
-
dev?: boolean;
|
|
133
|
-
}
|