@fgv/ts-res-browser-cli 5.0.0-4 → 5.0.0-6
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/.rush/temp/chunked-rush-logs/ts-res-browser-cli.build.chunks.jsonl +2 -2
- package/.rush/temp/{c4f97514f2c22774e10e40ef884aa8a976726219.tar.log → e396976e8696a2ca8b87b25896a78681780d28b3.tar.log} +6 -6
- package/.rush/temp/operation/build/all.log +2 -2
- package/.rush/temp/operation/build/log-chunks.jsonl +2 -2
- package/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/shrinkwrap-deps.json +1 -1
- package/README.md +35 -11
- package/lib/cli.d.ts +0 -4
- package/lib/cli.d.ts.map +1 -1
- package/lib/cli.js +8 -17
- package/lib/cli.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/options.d.ts +5 -0
- package/lib/options.d.ts.map +1 -1
- package/lib/options.js.map +1 -1
- package/lib/simpleBrowserLauncher.d.ts +32 -0
- package/lib/simpleBrowserLauncher.d.ts.map +1 -0
- package/lib/{browserLauncher.js → simpleBrowserLauncher.js} +53 -163
- package/lib/simpleBrowserLauncher.js.map +1 -0
- package/package.json +7 -6
- package/rush-logs/ts-res-browser-cli.build.cache.log +1 -1
- package/rush-logs/ts-res-browser-cli.build.log +2 -2
- package/src/cli.ts +17 -20
- package/src/index.ts +1 -1
- package/src/options.ts +6 -0
- package/src/{browserLauncher.ts → simpleBrowserLauncher.ts} +56 -186
- package/lib/browserLauncher.d.ts +0 -57
- package/lib/browserLauncher.d.ts.map +0 -1
- package/lib/browserLauncher.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{"kind":"O","text":"Invoking: heft build --clean \n"}
|
|
2
2
|
{"kind":"O","text":" ---- build started ---- \n"}
|
|
3
3
|
{"kind":"O","text":"[build:typescript] Using TypeScript version 5.8.3\n"}
|
|
4
|
-
{"kind":"O","text":" ---- build finished (
|
|
5
|
-
{"kind":"O","text":"-------------------- Finished (
|
|
4
|
+
{"kind":"O","text":" ---- build finished (2.334s) ---- \n"}
|
|
5
|
+
{"kind":"O","text":"-------------------- Finished (2.337s) --------------------\n"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
Start time:
|
|
2
|
-
Invoking "/usr/bin/tar -c -f /home/runner/work/fgv/fgv/common/temp/build-cache/
|
|
1
|
+
Start time: Fri Jul 25 2025 16:36:56 GMT+0000 (Coordinated Universal Time)
|
|
2
|
+
Invoking "/usr/bin/tar -c -f /home/runner/work/fgv/fgv/common/temp/build-cache/e396976e8696a2ca8b87b25896a78681780d28b3-3faf9226354a9b7f.temp -z --files-from=-"
|
|
3
3
|
|
|
4
4
|
======= BEGIN PROCESS INPUT ======
|
|
5
5
|
.rush/temp/operation/build/all.log
|
|
6
6
|
.rush/temp/operation/build/log-chunks.jsonl
|
|
7
7
|
.rush/temp/operation/build/state.json
|
|
8
|
-
lib/browserLauncher.d.ts
|
|
9
|
-
lib/browserLauncher.d.ts.map
|
|
10
|
-
lib/browserLauncher.js
|
|
11
|
-
lib/browserLauncher.js.map
|
|
12
8
|
lib/cli.d.ts
|
|
13
9
|
lib/cli.d.ts.map
|
|
14
10
|
lib/cli.js
|
|
@@ -21,6 +17,10 @@ lib/options.d.ts
|
|
|
21
17
|
lib/options.d.ts.map
|
|
22
18
|
lib/options.js
|
|
23
19
|
lib/options.js.map
|
|
20
|
+
lib/simpleBrowserLauncher.d.ts
|
|
21
|
+
lib/simpleBrowserLauncher.d.ts.map
|
|
22
|
+
lib/simpleBrowserLauncher.js
|
|
23
|
+
lib/simpleBrowserLauncher.js.map
|
|
24
24
|
lib/zipArchiver.d.ts
|
|
25
25
|
lib/zipArchiver.d.ts.map
|
|
26
26
|
lib/zipArchiver.js
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Invoking: heft build --clean
|
|
2
2
|
---- build started ----
|
|
3
3
|
[build:typescript] Using TypeScript version 5.8.3
|
|
4
|
-
---- build finished (
|
|
5
|
-
-------------------- Finished (
|
|
4
|
+
---- build finished (2.334s) ----
|
|
5
|
+
-------------------- Finished (2.337s) --------------------
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{"kind":"O","text":"Invoking: heft build --clean \n"}
|
|
2
2
|
{"kind":"O","text":" ---- build started ---- \n"}
|
|
3
3
|
{"kind":"O","text":"[build:typescript] Using TypeScript version 5.8.3\n"}
|
|
4
|
-
{"kind":"O","text":" ---- build finished (
|
|
5
|
-
{"kind":"O","text":"-------------------- Finished (
|
|
4
|
+
{"kind":"O","text":" ---- build finished (2.334s) ---- \n"}
|
|
5
|
+
{"kind":"O","text":"-------------------- Finished (2.337s) --------------------\n"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../tools/ts-res-browser-cli": "../../tools/ts-res-browser-cli:
|
|
2
|
+
"../../tools/ts-res-browser-cli": "../../tools/ts-res-browser-cli:HX/O4SzTTBSreQ71aBpJx2llZk9QhYUATyqYdAR692U=:",
|
|
3
3
|
"/@aashutoshrathi/word-wrap@1.2.6": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==",
|
|
4
4
|
"/@ampproject/remapping@2.2.0": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==",
|
|
5
5
|
"/@babel/code-frame@7.21.4": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==",
|
package/README.md
CHANGED
|
@@ -17,19 +17,28 @@ Command-line interface to launch ts-res-browser with specified resources and con
|
|
|
17
17
|
npm install -g @fgv/ts-res-browser-cli
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
Or use directly with npx (no installation required):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @fgv/ts-res-browser-cli --help
|
|
24
|
+
```
|
|
25
|
+
|
|
20
26
|
## Usage
|
|
21
27
|
|
|
22
28
|
### Basic Usage
|
|
23
29
|
|
|
24
30
|
```bash
|
|
25
31
|
# Launch browser with resources from a directory
|
|
26
|
-
ts-res-browser-cli browse --input ./resources --config default
|
|
32
|
+
ts-res-browser-cli browse --input ./resources --config default --serve
|
|
33
|
+
|
|
34
|
+
# With npx (no installation required)
|
|
35
|
+
npx @fgv/ts-res-browser-cli --input ./resources --config default --serve
|
|
27
36
|
|
|
28
37
|
# Launch with a specific configuration file
|
|
29
|
-
ts-res-browser-cli browse --input ./my-resources --config ./config.json
|
|
38
|
+
ts-res-browser-cli browse --input ./my-resources --config ./config.json --serve
|
|
30
39
|
|
|
31
40
|
# Create ZIP and launch without opening browser automatically
|
|
32
|
-
ts-res-browser-cli browse --input ./resources --config extended-example --no-open
|
|
41
|
+
ts-res-browser-cli browse --input ./resources --config extended-example --serve --no-open
|
|
33
42
|
```
|
|
34
43
|
|
|
35
44
|
### ZIP Workflow
|
|
@@ -42,19 +51,33 @@ The CLI automatically creates ZIP archives containing your resources and configu
|
|
|
42
51
|
|
|
43
52
|
```bash
|
|
44
53
|
# Creates: ~/Downloads/ts-res-bundle-[timestamp].zip
|
|
45
|
-
ts-res-browser-cli browse --input ./resources --config my-config
|
|
54
|
+
ts-res-browser-cli browse --input ./resources --config my-config --serve
|
|
46
55
|
```
|
|
47
56
|
|
|
48
|
-
###
|
|
57
|
+
### Server Options
|
|
58
|
+
|
|
59
|
+
The CLI provides several ways to launch the browser with a server:
|
|
49
60
|
|
|
50
61
|
```bash
|
|
51
|
-
#
|
|
62
|
+
# Recommended: Universal server start (works everywhere)
|
|
63
|
+
ts-res-browser-cli browse --input ./resources --serve
|
|
64
|
+
|
|
65
|
+
# Development server (monorepo environment only)
|
|
52
66
|
ts-res-browser-cli browse --input ./resources --dev
|
|
53
67
|
|
|
54
|
-
#
|
|
68
|
+
# Connect to existing server
|
|
55
69
|
ts-res-browser-cli browse --input ./resources --url http://localhost:3001
|
|
56
70
|
```
|
|
57
71
|
|
|
72
|
+
**Server Flag Behavior:**
|
|
73
|
+
- `--serve`: Works in both monorepo and published packages
|
|
74
|
+
- **Monorepo**: Starts webpack dev server with hot reloading (port 3000)
|
|
75
|
+
- **Published packages**: Starts static file server (port 8080)
|
|
76
|
+
- `--dev`: Development server with hot reloading (monorepo only)
|
|
77
|
+
- **Monorepo**: Same as `--serve`
|
|
78
|
+
- **Published packages**: Shows error with instructions to use `--serve`
|
|
79
|
+
- `--url`: Connect to existing server at specified URL
|
|
80
|
+
|
|
58
81
|
### Advanced Options
|
|
59
82
|
|
|
60
83
|
```bash
|
|
@@ -64,8 +87,8 @@ ts-res-browser-cli browse \
|
|
|
64
87
|
--context-filter "language=en-US|territory=US" \
|
|
65
88
|
--reduce-qualifiers
|
|
66
89
|
|
|
67
|
-
# Interactive mode with sample data
|
|
68
|
-
ts-res-browser-cli browse --interactive
|
|
90
|
+
# Interactive mode with sample data (requires server)
|
|
91
|
+
ts-res-browser-cli browse --interactive --serve
|
|
69
92
|
|
|
70
93
|
# Verbose output
|
|
71
94
|
ts-res-browser-cli browse --input ./resources --verbose
|
|
@@ -89,8 +112,9 @@ Launch ts-res-browser with specified resources and configuration.
|
|
|
89
112
|
- `-p, --port <number>`: Port for local browser instance
|
|
90
113
|
- `--url <url>`: URL of remote browser instance
|
|
91
114
|
- `--no-open`: Do not open browser automatically
|
|
92
|
-
- `--interactive`: Launch in interactive mode with sample data
|
|
93
|
-
- `--
|
|
115
|
+
- `--interactive`: Launch in interactive mode with sample data (requires --serve, --dev, or --url)
|
|
116
|
+
- `--serve`: Start server (dev in monorepo, serve in published packages) and connect automatically
|
|
117
|
+
- `--dev`: Start development server locally (monorepo only)
|
|
94
118
|
- `-v, --verbose`: Verbose output
|
|
95
119
|
- `-q, --quiet`: Quiet output
|
|
96
120
|
|
package/lib/cli.d.ts
CHANGED
package/lib/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AA+BA;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;;IAQlD;;OAEG;IACU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;OAEG;IACH,OAAO,CAAC,cAAc;IA6GtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;YACW,oBAAoB;IAclC;;OAEG;YACW,oBAAoB;IA6KlC;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAwC5B"}
|
package/lib/cli.js
CHANGED
|
@@ -60,16 +60,15 @@ const ts_utils_1 = require("@fgv/ts-utils");
|
|
|
60
60
|
const TsRes = __importStar(require("@fgv/ts-res"));
|
|
61
61
|
const fs_1 = require("fs");
|
|
62
62
|
const path = __importStar(require("path"));
|
|
63
|
-
const
|
|
63
|
+
const simpleBrowserLauncher_1 = require("./simpleBrowserLauncher");
|
|
64
64
|
/**
|
|
65
65
|
* Main CLI class for ts-res-browser-cli
|
|
66
66
|
*/
|
|
67
67
|
class TsResBrowserCliApp {
|
|
68
68
|
constructor() {
|
|
69
69
|
this._program = new commander_1.Command();
|
|
70
|
-
this._launcher = new
|
|
70
|
+
this._launcher = new simpleBrowserLauncher_1.SimpleBrowserLauncher();
|
|
71
71
|
this._setupCommands();
|
|
72
|
-
this._setupGracefulShutdown();
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
74
|
* Runs the CLI with the provided arguments
|
|
@@ -102,6 +101,7 @@ class TsResBrowserCliApp {
|
|
|
102
101
|
.option('--no-open', 'Do not open browser automatically')
|
|
103
102
|
.option('--interactive', 'Launch in interactive mode with sample data', false)
|
|
104
103
|
.option('--dev', 'Automatically start development server locally', false)
|
|
104
|
+
.option('--serve', 'Start server (dev in monorepo, serve in published packages) and connect automatically', false)
|
|
105
105
|
.action(async (options) => {
|
|
106
106
|
// If no options provided, show help
|
|
107
107
|
if (!this._hasOptions(options)) {
|
|
@@ -130,6 +130,7 @@ class TsResBrowserCliApp {
|
|
|
130
130
|
.option('--no-open', 'Do not open browser automatically')
|
|
131
131
|
.option('--interactive', 'Launch in interactive mode with sample data', false)
|
|
132
132
|
.option('--dev', 'Automatically start development server locally', false)
|
|
133
|
+
.option('--serve', 'Start server (dev in monorepo, serve in published packages) and connect automatically', false)
|
|
133
134
|
.action(async (options) => {
|
|
134
135
|
await this._handleBrowseCommand(options);
|
|
135
136
|
});
|
|
@@ -161,7 +162,8 @@ class TsResBrowserCliApp {
|
|
|
161
162
|
options.reduceQualifiers ||
|
|
162
163
|
options.interactive ||
|
|
163
164
|
options.url ||
|
|
164
|
-
options.dev
|
|
165
|
+
options.dev ||
|
|
166
|
+
options.serve);
|
|
165
167
|
}
|
|
166
168
|
/**
|
|
167
169
|
* Handles the browse command
|
|
@@ -348,7 +350,8 @@ class TsResBrowserCliApp {
|
|
|
348
350
|
url: options.url,
|
|
349
351
|
open: options.open,
|
|
350
352
|
interactive: options.interactive || false,
|
|
351
|
-
dev: options.dev || false
|
|
353
|
+
dev: options.dev || false,
|
|
354
|
+
serve: options.serve || false
|
|
352
355
|
};
|
|
353
356
|
return (0, ts_utils_1.succeed)(browseOptions);
|
|
354
357
|
}
|
|
@@ -356,18 +359,6 @@ class TsResBrowserCliApp {
|
|
|
356
359
|
return (0, ts_utils_1.fail)(`Failed to parse options: ${error}`);
|
|
357
360
|
}
|
|
358
361
|
}
|
|
359
|
-
/**
|
|
360
|
-
* Sets up graceful shutdown handling
|
|
361
|
-
*/
|
|
362
|
-
_setupGracefulShutdown() {
|
|
363
|
-
const shutdown = (signal) => {
|
|
364
|
-
console.log(`\nReceived ${signal}, shutting down gracefully...`);
|
|
365
|
-
this._launcher.shutdown();
|
|
366
|
-
process.exit(0);
|
|
367
|
-
};
|
|
368
|
-
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
369
|
-
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
370
|
-
}
|
|
371
362
|
}
|
|
372
363
|
exports.TsResBrowserCliApp = TsResBrowserCliApp;
|
|
373
364
|
//# sourceMappingURL=cli.js.map
|
package/lib/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,4CAAsD;AACtD,mDAAqC;AACrC,2BAAoC;AACpC,2CAA6B;AAG7B,uDAAoD;AAEpD;;GAEG;AACH,MAAa,kBAAkB;IAI7B;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAe,EAAE,CAAC;QACvC,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,sBAAsB,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,IAAc;QAC7B,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,IAAI,CAAC,QAAQ;aACV,IAAI,CAAC,oBAAoB,CAAC;aAC1B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C,WAAW;gBAChC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;gBACnD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;gBACjC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;gBAC7B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK;gBACzC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK;aAC1B,CAAC;YAEF,OAAO,IAAA,kBAAO,EAAC,aAAa,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,eAAI,EAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED;;OAEG;IACK,sBAAsB;QAC5B,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,EAAE;YAClC,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,+BAA+B,CAAC,CAAC;YACjE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACnD,CAAC;CACF;AApYD,gDAoYC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Command } from 'commander';\nimport { Result, succeed, fail } from '@fgv/ts-utils';\nimport * as TsRes from '@fgv/ts-res';\nimport { promises as fs } from 'fs';\nimport * as path from 'path';\n\nimport { IBrowseOptions, IBrowseCommandOptions } from './options';\nimport { BrowserLauncher } from './browserLauncher';\n\n/**\n * Main CLI class for ts-res-browser-cli\n */\nexport class TsResBrowserCliApp {\n private readonly _program: Command;\n private readonly _launcher: BrowserLauncher;\n\n public constructor() {\n this._program = new Command();\n this._launcher = new BrowserLauncher();\n this._setupCommands();\n this._setupGracefulShutdown();\n }\n\n /**\n * Runs the CLI with the provided arguments\n */\n public async run(argv: string[]): Promise<void> {\n await this._program.parseAsync(argv);\n }\n\n /**\n * Sets up the CLI commands and options\n */\n private _setupCommands(): void {\n this._program\n .name('ts-res-browser-cli')\n .description('Launch ts-res-browser with specified resources and configuration')\n .version('1.0.0');\n\n // Default behavior (no command) - launch with options or show help\n this._program\n .option('-i, --input <path>', 'Input file or directory path')\n .option(\n '--config <name|path>',\n 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'\n )\n .option('-c, --context <json>', 'Context filter for resources (JSON string)')\n .option(\n '--context-filter <token>',\n 'Context filter token (pipe-separated, e.g., \"language=en-US|territory=US\")'\n )\n .option(\n '--qualifier-defaults <token>',\n 'Qualifier default values token (pipe-separated, e.g., \"language=en-US,en-CA|territory=US\")'\n )\n .option('--resource-types <types>', 'Resource type filter (comma-separated)')\n .option('--max-distance <number>', 'Maximum distance for language matching', parseInt)\n .option(\n '--reduce-qualifiers',\n 'Remove perfectly matching qualifier conditions from filtered resources',\n false\n )\n .option('-v, --verbose', 'Verbose output', false)\n .option('-q, --quiet', 'Quiet output', false)\n .option('-p, --port <number>', 'Port for local browser instance', parseInt)\n .option('--url <url>', 'URL of remote browser instance')\n .option('--no-open', 'Do not open browser automatically')\n .option('--interactive', 'Launch in interactive mode with sample data', false)\n .option('--dev', 'Automatically start development server locally', false)\n .action(async (options) => {\n // If no options provided, show help\n if (!this._hasOptions(options)) {\n this._program.help();\n } else {\n await this._handleBrowseCommand(options);\n }\n });\n\n // Browse command (explicit)\n this._program\n .command('browse')\n .description('Launch browser with specified resources and configuration')\n .option('-i, --input <path>', 'Input file or directory path')\n .option(\n '--config <name|path>',\n 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'\n )\n .option('-c, --context <json>', 'Context filter for resources (JSON string)')\n .option(\n '--context-filter <token>',\n 'Context filter token (pipe-separated, e.g., \"language=en-US|territory=US\")'\n )\n .option(\n '--qualifier-defaults <token>',\n 'Qualifier default values token (pipe-separated, e.g., \"language=en-US,en-CA|territory=US\")'\n )\n .option('--resource-types <types>', 'Resource type filter (comma-separated)')\n .option('--max-distance <number>', 'Maximum distance for language matching', parseInt)\n .option(\n '--reduce-qualifiers',\n 'Remove perfectly matching qualifier conditions from filtered resources',\n false\n )\n .option('-v, --verbose', 'Verbose output', false)\n .option('-q, --quiet', 'Quiet output', false)\n .option('-p, --port <number>', 'Port for local browser instance', parseInt)\n .option('--url <url>', 'URL of remote browser instance')\n .option('--no-open', 'Do not open browser automatically')\n .option('--interactive', 'Launch in interactive mode with sample data', false)\n .option('--dev', 'Automatically start development server locally', false)\n .action(async (options) => {\n await this._handleBrowseCommand(options);\n });\n\n // Config command (similar to ts-res-cli)\n this._program\n .command('config')\n .description('Manage system configurations')\n .option('-n, --name <name>', 'Predefined configuration name to print')\n .option('-o, --output <path>', 'Output file path to save configuration')\n .option('--validate <path>', 'Validate a configuration file')\n .option('--normalize <path>', 'Normalize and validate a configuration file')\n .option(\n '--qualifier-defaults <token>',\n 'Qualifier default values token (pipe-separated, e.g., \"language=en-US,en-CA|territory=US\")'\n )\n .option('-l, --list', 'List all available predefined configurations')\n .action(async (options) => {\n await this._handleConfigCommand(options);\n });\n }\n\n /**\n * Check if any meaningful options were provided\n */\n private _hasOptions(options: IBrowseCommandOptions): boolean {\n return !!(\n options.input ||\n options.config ||\n options.context ||\n options.contextFilter ||\n options.qualifierDefaults ||\n options.resourceTypes ||\n options.maxDistance !== undefined ||\n options.reduceQualifiers ||\n options.interactive ||\n options.url ||\n options.dev\n );\n }\n\n /**\n * Handles the browse command\n */\n private async _handleBrowseCommand(options: IBrowseCommandOptions): Promise<void> {\n const browseOptions = this._parseBrowseOptions(options);\n if (browseOptions.isFailure()) {\n console.error(`Error: ${browseOptions.message}`);\n process.exit(1);\n }\n\n const result = await this._launcher.launch(browseOptions.value);\n if (result.isFailure()) {\n console.error(`Error: ${result.message}`);\n process.exit(1);\n }\n }\n\n /**\n * Handles the config command (similar to ts-res-cli)\n */\n private async _handleConfigCommand(options: any): Promise<void> {\n try {\n // List all predefined configurations\n if (options.list) {\n console.log('Available predefined configurations:');\n console.log('- default');\n console.log('- language-priority');\n console.log('- territory-priority');\n console.log('- extended-example');\n return;\n }\n\n // Print a specific predefined configuration\n if (options.name) {\n const predefinedNames: TsRes.Config.PredefinedSystemConfiguration[] = [\n 'default',\n 'language-priority',\n 'territory-priority',\n 'extended-example'\n ];\n\n if (!predefinedNames.includes(options.name as TsRes.Config.PredefinedSystemConfiguration)) {\n console.error(`Error: Predefined configuration '${options.name}' not found`);\n console.error(\n 'Available configurations: default, language-priority, territory-priority, extended-example'\n );\n process.exit(1);\n }\n\n const configResult = TsRes.Config.getPredefinedDeclaration(\n options.name as TsRes.Config.PredefinedSystemConfiguration\n );\n if (configResult.isFailure()) {\n console.error(\n `Error: Failed to load predefined configuration '${options.name}': ${configResult.message}`\n );\n process.exit(1);\n }\n\n let config = configResult.value;\n\n // Apply qualifier defaults if provided\n if (options.qualifierDefaults) {\n const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(config);\n if (tempSystemConfigResult.isFailure()) {\n console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);\n process.exit(1);\n }\n\n const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(\n tempSystemConfigResult.value.qualifiers\n );\n const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);\n if (defaultsResult.isFailure()) {\n console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);\n process.exit(1);\n }\n\n const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(\n config,\n defaultsResult.value\n );\n if (updatedConfigResult.isFailure()) {\n console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);\n process.exit(1);\n }\n\n config = updatedConfigResult.value;\n }\n\n const output = JSON.stringify(config, null, 2);\n\n if (options.output) {\n const outputPath = path.resolve(options.output);\n const outputDir = path.dirname(outputPath);\n\n await fs.mkdir(outputDir, { recursive: true });\n await fs.writeFile(outputPath, output, 'utf-8');\n console.log(`Configuration saved to: ${outputPath}`);\n } else {\n console.log(output);\n }\n return;\n }\n\n // Validate a configuration file\n if (options.validate) {\n const configPath = path.resolve(options.validate);\n const configContent = await fs.readFile(configPath, 'utf-8');\n const configData = JSON.parse(configContent);\n\n const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);\n if (configResult.isFailure()) {\n console.error(`Validation failed: ${configResult.message}`);\n process.exit(1);\n }\n\n console.log(`Configuration file '${configPath}' is valid`);\n return;\n }\n\n // Normalize a configuration file\n if (options.normalize) {\n const configPath = path.resolve(options.normalize);\n const configContent = await fs.readFile(configPath, 'utf-8');\n const configData = JSON.parse(configContent);\n\n const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);\n if (configResult.isFailure()) {\n console.error(`Normalization failed: ${configResult.message}`);\n process.exit(1);\n }\n\n let normalizedConfig = configResult.value;\n\n // Apply qualifier defaults if provided\n if (options.qualifierDefaults) {\n const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(normalizedConfig);\n if (tempSystemConfigResult.isFailure()) {\n console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);\n process.exit(1);\n }\n\n const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(\n tempSystemConfigResult.value.qualifiers\n );\n const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);\n if (defaultsResult.isFailure()) {\n console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);\n process.exit(1);\n }\n\n const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(\n normalizedConfig,\n defaultsResult.value\n );\n if (updatedConfigResult.isFailure()) {\n console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);\n process.exit(1);\n }\n\n normalizedConfig = updatedConfigResult.value;\n }\n\n const output = JSON.stringify(normalizedConfig, null, 2);\n\n if (options.output) {\n const outputPath = path.resolve(options.output);\n const outputDir = path.dirname(outputPath);\n\n await fs.mkdir(outputDir, { recursive: true });\n await fs.writeFile(outputPath, output, 'utf-8');\n console.log(`Normalized configuration saved to: ${outputPath}`);\n } else {\n console.log(output);\n }\n return;\n }\n\n // If no specific action, print default configuration\n const defaultResult = TsRes.Config.getPredefinedDeclaration('default');\n if (defaultResult.isFailure()) {\n console.error(`Error: Default configuration not available`);\n process.exit(1);\n }\n\n console.log(JSON.stringify(defaultResult.value, null, 2));\n } catch (error) {\n console.error(`Error: ${error}`);\n process.exit(1);\n }\n }\n\n /**\n * Parses and validates browse options\n */\n private _parseBrowseOptions(options: IBrowseCommandOptions): Result<IBrowseOptions> {\n try {\n // Convert JSON context to contextFilter if provided\n let contextFilter = options.contextFilter;\n if (options.context && !contextFilter) {\n try {\n const contextObj = JSON.parse(options.context);\n const tokens: string[] = [];\n for (const [key, value] of Object.entries(contextObj)) {\n tokens.push(`${key}=${value}`);\n }\n contextFilter = tokens.join('|');\n } catch (error) {\n return fail(`Invalid context JSON: ${error}`);\n }\n }\n\n const browseOptions: IBrowseOptions = {\n input: options.input,\n config: options.config,\n contextFilter,\n qualifierDefaults: options.qualifierDefaults,\n resourceTypes: options.resourceTypes,\n maxDistance: options.maxDistance,\n reduceQualifiers: options.reduceQualifiers || false,\n verbose: options.verbose || false,\n quiet: options.quiet || false,\n port: options.port,\n url: options.url,\n open: options.open,\n interactive: options.interactive || false,\n dev: options.dev || false\n };\n\n return succeed(browseOptions);\n } catch (error) {\n return fail(`Failed to parse options: ${error}`);\n }\n }\n\n /**\n * Sets up graceful shutdown handling\n */\n private _setupGracefulShutdown(): void {\n const shutdown = (signal: string) => {\n console.log(`\\nReceived ${signal}, shutting down gracefully...`);\n this._launcher.shutdown();\n process.exit(0);\n };\n\n process.on('SIGINT', () => shutdown('SIGINT'));\n process.on('SIGTERM', () => shutdown('SIGTERM'));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,4CAAsD;AACtD,mDAAqC;AACrC,2BAAoC;AACpC,2CAA6B;AAG7B,mEAAgE;AAEhE;;GAEG;AACH,MAAa,kBAAkB;IAI7B;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,mBAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,6CAAqB,EAAE,CAAC;QAC7C,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACI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AK,EAAE,CAAC;oBACf,OAAO,IAAA,eAAI,EAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;gBAChD,CAAC;YACH,CAAC;YAED,MAAM,aAAa,GAAmB;gBACpC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,aAAa;gBACb,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;gBAC5C,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;gBACnD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;gBACjC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;gBAC7B,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,KAAK;gBACzC,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,KAAK;gBACzB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;aAC9B,CAAC;YAEF,OAAO,IAAA,kBAAO,EAAC,aAAa,CAAC,CAAC;QAChC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAA,eAAI,EAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AAjYD,gDAiYC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Command } from 'commander';\nimport { Result, succeed, fail } from '@fgv/ts-utils';\nimport * as TsRes from '@fgv/ts-res';\nimport { promises as fs } from 'fs';\nimport * as path from 'path';\n\nimport { IBrowseOptions, IBrowseCommandOptions } from './options';\nimport { SimpleBrowserLauncher } from './simpleBrowserLauncher';\n\n/**\n * Main CLI class for ts-res-browser-cli\n */\nexport class TsResBrowserCliApp {\n private readonly _program: Command;\n private readonly _launcher: SimpleBrowserLauncher;\n\n public constructor() {\n this._program = new Command();\n this._launcher = new SimpleBrowserLauncher();\n this._setupCommands();\n }\n\n /**\n * Runs the CLI with the provided arguments\n */\n public async run(argv: string[]): Promise<void> {\n await this._program.parseAsync(argv);\n }\n\n /**\n * Sets up the CLI commands and options\n */\n private _setupCommands(): void {\n this._program\n .name('ts-res-browser-cli')\n .description('Launch ts-res-browser with specified resources and configuration')\n .version('1.0.0');\n\n // Default behavior (no command) - launch with options or show help\n this._program\n .option('-i, --input <path>', 'Input file or directory path')\n .option(\n '--config <name|path>',\n 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'\n )\n .option('-c, --context <json>', 'Context filter for resources (JSON string)')\n .option(\n '--context-filter <token>',\n 'Context filter token (pipe-separated, e.g., \"language=en-US|territory=US\")'\n )\n .option(\n '--qualifier-defaults <token>',\n 'Qualifier default values token (pipe-separated, e.g., \"language=en-US,en-CA|territory=US\")'\n )\n .option('--resource-types <types>', 'Resource type filter (comma-separated)')\n .option('--max-distance <number>', 'Maximum distance for language matching', parseInt)\n .option(\n '--reduce-qualifiers',\n 'Remove perfectly matching qualifier conditions from filtered resources',\n false\n )\n .option('-v, --verbose', 'Verbose output', false)\n .option('-q, --quiet', 'Quiet output', false)\n .option('-p, --port <number>', 'Port for local browser instance', parseInt)\n .option('--url <url>', 'URL of remote browser instance')\n .option('--no-open', 'Do not open browser automatically')\n .option('--interactive', 'Launch in interactive mode with sample data', false)\n .option('--dev', 'Automatically start development server locally', false)\n .option(\n '--serve',\n 'Start server (dev in monorepo, serve in published packages) and connect automatically',\n false\n )\n .action(async (options) => {\n // If no options provided, show help\n if (!this._hasOptions(options)) {\n this._program.help();\n } else {\n await this._handleBrowseCommand(options);\n }\n });\n\n // Browse command (explicit)\n this._program\n .command('browse')\n .description('Launch browser with specified resources and configuration')\n .option('-i, --input <path>', 'Input file or directory path')\n .option(\n '--config <name|path>',\n 'Predefined configuration name or system configuration file path (JSON, ISystemConfiguration format)'\n )\n .option('-c, --context <json>', 'Context filter for resources (JSON string)')\n .option(\n '--context-filter <token>',\n 'Context filter token (pipe-separated, e.g., \"language=en-US|territory=US\")'\n )\n .option(\n '--qualifier-defaults <token>',\n 'Qualifier default values token (pipe-separated, e.g., \"language=en-US,en-CA|territory=US\")'\n )\n .option('--resource-types <types>', 'Resource type filter (comma-separated)')\n .option('--max-distance <number>', 'Maximum distance for language matching', parseInt)\n .option(\n '--reduce-qualifiers',\n 'Remove perfectly matching qualifier conditions from filtered resources',\n false\n )\n .option('-v, --verbose', 'Verbose output', false)\n .option('-q, --quiet', 'Quiet output', false)\n .option('-p, --port <number>', 'Port for local browser instance', parseInt)\n .option('--url <url>', 'URL of remote browser instance')\n .option('--no-open', 'Do not open browser automatically')\n .option('--interactive', 'Launch in interactive mode with sample data', false)\n .option('--dev', 'Automatically start development server locally', false)\n .option(\n '--serve',\n 'Start server (dev in monorepo, serve in published packages) and connect automatically',\n false\n )\n .action(async (options) => {\n await this._handleBrowseCommand(options);\n });\n\n // Config command (similar to ts-res-cli)\n this._program\n .command('config')\n .description('Manage system configurations')\n .option('-n, --name <name>', 'Predefined configuration name to print')\n .option('-o, --output <path>', 'Output file path to save configuration')\n .option('--validate <path>', 'Validate a configuration file')\n .option('--normalize <path>', 'Normalize and validate a configuration file')\n .option(\n '--qualifier-defaults <token>',\n 'Qualifier default values token (pipe-separated, e.g., \"language=en-US,en-CA|territory=US\")'\n )\n .option('-l, --list', 'List all available predefined configurations')\n .action(async (options) => {\n await this._handleConfigCommand(options);\n });\n }\n\n /**\n * Check if any meaningful options were provided\n */\n private _hasOptions(options: IBrowseCommandOptions): boolean {\n return !!(\n options.input ||\n options.config ||\n options.context ||\n options.contextFilter ||\n options.qualifierDefaults ||\n options.resourceTypes ||\n options.maxDistance !== undefined ||\n options.reduceQualifiers ||\n options.interactive ||\n options.url ||\n options.dev ||\n options.serve\n );\n }\n\n /**\n * Handles the browse command\n */\n private async _handleBrowseCommand(options: IBrowseCommandOptions): Promise<void> {\n const browseOptions = this._parseBrowseOptions(options);\n if (browseOptions.isFailure()) {\n console.error(`Error: ${browseOptions.message}`);\n process.exit(1);\n }\n\n const result = await this._launcher.launch(browseOptions.value);\n if (result.isFailure()) {\n console.error(`Error: ${result.message}`);\n process.exit(1);\n }\n }\n\n /**\n * Handles the config command (similar to ts-res-cli)\n */\n private async _handleConfigCommand(options: any): Promise<void> {\n try {\n // List all predefined configurations\n if (options.list) {\n console.log('Available predefined configurations:');\n console.log('- default');\n console.log('- language-priority');\n console.log('- territory-priority');\n console.log('- extended-example');\n return;\n }\n\n // Print a specific predefined configuration\n if (options.name) {\n const predefinedNames: TsRes.Config.PredefinedSystemConfiguration[] = [\n 'default',\n 'language-priority',\n 'territory-priority',\n 'extended-example'\n ];\n\n if (!predefinedNames.includes(options.name as TsRes.Config.PredefinedSystemConfiguration)) {\n console.error(`Error: Predefined configuration '${options.name}' not found`);\n console.error(\n 'Available configurations: default, language-priority, territory-priority, extended-example'\n );\n process.exit(1);\n }\n\n const configResult = TsRes.Config.getPredefinedDeclaration(\n options.name as TsRes.Config.PredefinedSystemConfiguration\n );\n if (configResult.isFailure()) {\n console.error(\n `Error: Failed to load predefined configuration '${options.name}': ${configResult.message}`\n );\n process.exit(1);\n }\n\n let config = configResult.value;\n\n // Apply qualifier defaults if provided\n if (options.qualifierDefaults) {\n const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(config);\n if (tempSystemConfigResult.isFailure()) {\n console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);\n process.exit(1);\n }\n\n const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(\n tempSystemConfigResult.value.qualifiers\n );\n const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);\n if (defaultsResult.isFailure()) {\n console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);\n process.exit(1);\n }\n\n const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(\n config,\n defaultsResult.value\n );\n if (updatedConfigResult.isFailure()) {\n console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);\n process.exit(1);\n }\n\n config = updatedConfigResult.value;\n }\n\n const output = JSON.stringify(config, null, 2);\n\n if (options.output) {\n const outputPath = path.resolve(options.output);\n const outputDir = path.dirname(outputPath);\n\n await fs.mkdir(outputDir, { recursive: true });\n await fs.writeFile(outputPath, output, 'utf-8');\n console.log(`Configuration saved to: ${outputPath}`);\n } else {\n console.log(output);\n }\n return;\n }\n\n // Validate a configuration file\n if (options.validate) {\n const configPath = path.resolve(options.validate);\n const configContent = await fs.readFile(configPath, 'utf-8');\n const configData = JSON.parse(configContent);\n\n const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);\n if (configResult.isFailure()) {\n console.error(`Validation failed: ${configResult.message}`);\n process.exit(1);\n }\n\n console.log(`Configuration file '${configPath}' is valid`);\n return;\n }\n\n // Normalize a configuration file\n if (options.normalize) {\n const configPath = path.resolve(options.normalize);\n const configContent = await fs.readFile(configPath, 'utf-8');\n const configData = JSON.parse(configContent);\n\n const configResult = TsRes.Config.Convert.systemConfiguration.convert(configData);\n if (configResult.isFailure()) {\n console.error(`Normalization failed: ${configResult.message}`);\n process.exit(1);\n }\n\n let normalizedConfig = configResult.value;\n\n // Apply qualifier defaults if provided\n if (options.qualifierDefaults) {\n const tempSystemConfigResult = TsRes.Config.SystemConfiguration.create(normalizedConfig);\n if (tempSystemConfigResult.isFailure()) {\n console.error(`Error: Failed to create system configuration: ${tempSystemConfigResult.message}`);\n process.exit(1);\n }\n\n const tokens = new TsRes.Qualifiers.QualifierDefaultValueTokens(\n tempSystemConfigResult.value.qualifiers\n );\n const defaultsResult = tokens.qualifierDefaultValuesTokenToDecl(options.qualifierDefaults);\n if (defaultsResult.isFailure()) {\n console.error(`Error: Failed to parse qualifier defaults: ${defaultsResult.message}`);\n process.exit(1);\n }\n\n const updatedConfigResult = TsRes.Config.updateSystemConfigurationQualifierDefaultValues(\n normalizedConfig,\n defaultsResult.value\n );\n if (updatedConfigResult.isFailure()) {\n console.error(`Error: Failed to apply qualifier defaults: ${updatedConfigResult.message}`);\n process.exit(1);\n }\n\n normalizedConfig = updatedConfigResult.value;\n }\n\n const output = JSON.stringify(normalizedConfig, null, 2);\n\n if (options.output) {\n const outputPath = path.resolve(options.output);\n const outputDir = path.dirname(outputPath);\n\n await fs.mkdir(outputDir, { recursive: true });\n await fs.writeFile(outputPath, output, 'utf-8');\n console.log(`Normalized configuration saved to: ${outputPath}`);\n } else {\n console.log(output);\n }\n return;\n }\n\n // If no specific action, print default configuration\n const defaultResult = TsRes.Config.getPredefinedDeclaration('default');\n if (defaultResult.isFailure()) {\n console.error(`Error: Default configuration not available`);\n process.exit(1);\n }\n\n console.log(JSON.stringify(defaultResult.value, null, 2));\n } catch (error) {\n console.error(`Error: ${error}`);\n process.exit(1);\n }\n }\n\n /**\n * Parses and validates browse options\n */\n private _parseBrowseOptions(options: IBrowseCommandOptions): Result<IBrowseOptions> {\n try {\n // Convert JSON context to contextFilter if provided\n let contextFilter = options.contextFilter;\n if (options.context && !contextFilter) {\n try {\n const contextObj = JSON.parse(options.context);\n const tokens: string[] = [];\n for (const [key, value] of Object.entries(contextObj)) {\n tokens.push(`${key}=${value}`);\n }\n contextFilter = tokens.join('|');\n } catch (error) {\n return fail(`Invalid context JSON: ${error}`);\n }\n }\n\n const browseOptions: IBrowseOptions = {\n input: options.input,\n config: options.config,\n contextFilter,\n qualifierDefaults: options.qualifierDefaults,\n resourceTypes: options.resourceTypes,\n maxDistance: options.maxDistance,\n reduceQualifiers: options.reduceQualifiers || false,\n verbose: options.verbose || false,\n quiet: options.quiet || false,\n port: options.port,\n url: options.url,\n open: options.open,\n interactive: options.interactive || false,\n dev: options.dev || false,\n serve: options.serve || false\n };\n\n return succeed(browseOptions);\n } catch (error) {\n return fail(`Failed to parse options: ${error}`);\n }\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -38,5 +38,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
// Export main components
|
|
39
39
|
__exportStar(require("./cli"), exports);
|
|
40
40
|
__exportStar(require("./options"), exports);
|
|
41
|
-
__exportStar(require("./
|
|
41
|
+
__exportStar(require("./simpleBrowserLauncher"), exports);
|
|
42
42
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,yBAAyB;AACzB,wCAAsB;AACtB,4CAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,yBAAyB;AACzB,wCAAsB;AACtB,4CAA0B;AAC1B,0DAAwC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Export main components\nexport * from './cli';\nexport * from './options';\nexport * from './simpleBrowserLauncher';\n"]}
|
package/lib/options.d.ts
CHANGED
|
@@ -59,6 +59,10 @@ export interface IBrowseOptions {
|
|
|
59
59
|
* Whether to automatically start the development server
|
|
60
60
|
*/
|
|
61
61
|
dev?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether to start server (dev in monorepo, serve in published packages) and connect automatically
|
|
64
|
+
*/
|
|
65
|
+
serve?: boolean;
|
|
62
66
|
/**
|
|
63
67
|
* Whether to use ZIP loading mode (internal flag)
|
|
64
68
|
*/
|
|
@@ -91,5 +95,6 @@ export interface IBrowseCommandOptions {
|
|
|
91
95
|
interactive?: boolean;
|
|
92
96
|
url?: string;
|
|
93
97
|
dev?: boolean;
|
|
98
|
+
serve?: boolean;
|
|
94
99
|
}
|
|
95
100
|
//# sourceMappingURL=options.d.ts.map
|
package/lib/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;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appings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Options for launching the ts-res browser\n */\nexport interface IBrowseOptions {\n /**\n * Input file or directory path\n */\n input?: string;\n\n /**\n * System configuration file path (JSON file in ISystemConfiguration format)\n * or predefined configuration name\n */\n config?: string;\n\n /**\n * Context filter token (pipe-separated qualifier=value pairs, e.g., 'language=en-US|territory=US')\n */\n contextFilter?: string;\n\n /**\n * Qualifier default values token (pipe-separated qualifier=value pairs, e.g., 'language=en-US,en-CA|territory=US')\n */\n qualifierDefaults?: string;\n\n /**\n * Resource types filter (comma-separated, e.g., 'json,string')\n */\n resourceTypes?: string;\n\n /**\n * Maximum distance for language matching\n */\n maxDistance?: number;\n\n /**\n * Whether to reduce qualifiers when filtering by context\n */\n reduceQualifiers?: boolean;\n\n /**\n * Whether to run in verbose mode\n */\n verbose?: boolean;\n\n /**\n * Whether to run in quiet mode\n */\n quiet?: boolean;\n\n /**\n * Port to run the development server on (for launching locally)\n */\n port?: number;\n\n /**\n * Whether to open the browser automatically\n */\n open?: boolean;\n\n /**\n * Whether to launch in interactive mode (with sample data)\n */\n interactive?: boolean;\n\n /**\n * Browser URL to launch (for remote instances)\n */\n url?: string;\n\n /**\n * Whether to automatically start the development server\n */\n dev?: boolean;\n\n /**\n * Whether to use ZIP loading mode (internal flag)\n */\n loadZip?: boolean;\n\n /**\n * Path to ZIP file to load (internal flag)\n */\n zipPath?: string;\n\n /**\n * Name of ZIP file to load (internal flag)\n */\n zipFile?: string;\n}\n\n/**\n * Command-line options for the browse command\n */\nexport interface IBrowseCommandOptions {\n input?: string;\n config?: string;\n context?: string;\n contextFilter?: string;\n qualifierDefaults?: string;\n resourceTypes?: string;\n maxDistance?: number;\n reduceQualifiers?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n port?: number;\n open?: boolean;\n interactive?: boolean;\n url?: string;\n dev?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Options for launching the ts-res browser\n */\nexport interface IBrowseOptions {\n /**\n * Input file or directory path\n */\n input?: string;\n\n /**\n * System configuration file path (JSON file in ISystemConfiguration format)\n * or predefined configuration name\n */\n config?: string;\n\n /**\n * Context filter token (pipe-separated qualifier=value pairs, e.g., 'language=en-US|territory=US')\n */\n contextFilter?: string;\n\n /**\n * Qualifier default values token (pipe-separated qualifier=value pairs, e.g., 'language=en-US,en-CA|territory=US')\n */\n qualifierDefaults?: string;\n\n /**\n * Resource types filter (comma-separated, e.g., 'json,string')\n */\n resourceTypes?: string;\n\n /**\n * Maximum distance for language matching\n */\n maxDistance?: number;\n\n /**\n * Whether to reduce qualifiers when filtering by context\n */\n reduceQualifiers?: boolean;\n\n /**\n * Whether to run in verbose mode\n */\n verbose?: boolean;\n\n /**\n * Whether to run in quiet mode\n */\n quiet?: boolean;\n\n /**\n * Port to run the development server on (for launching locally)\n */\n port?: number;\n\n /**\n * Whether to open the browser automatically\n */\n open?: boolean;\n\n /**\n * Whether to launch in interactive mode (with sample data)\n */\n interactive?: boolean;\n\n /**\n * Browser URL to launch (for remote instances)\n */\n url?: string;\n\n /**\n * Whether to automatically start the development server\n */\n dev?: boolean;\n\n /**\n * Whether to start server (dev in monorepo, serve in published packages) and connect automatically\n */\n serve?: boolean;\n\n /**\n * Whether to use ZIP loading mode (internal flag)\n */\n loadZip?: boolean;\n\n /**\n * Path to ZIP file to load (internal flag)\n */\n zipPath?: string;\n\n /**\n * Name of ZIP file to load (internal flag)\n */\n zipFile?: string;\n}\n\n/**\n * Command-line options for the browse command\n */\nexport interface IBrowseCommandOptions {\n input?: string;\n config?: string;\n context?: string;\n contextFilter?: string;\n qualifierDefaults?: string;\n resourceTypes?: string;\n maxDistance?: number;\n reduceQualifiers?: boolean;\n verbose?: boolean;\n quiet?: boolean;\n port?: number;\n open?: boolean;\n interactive?: boolean;\n url?: string;\n dev?: boolean;\n serve?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
import { IBrowseOptions } from './options';
|
|
3
|
+
/**
|
|
4
|
+
* Simplified browser launcher using direct dependency on ts-res-browser
|
|
5
|
+
*/
|
|
6
|
+
export declare class SimpleBrowserLauncher {
|
|
7
|
+
/**
|
|
8
|
+
* Launches the browser with the specified options
|
|
9
|
+
*/
|
|
10
|
+
launch(options: IBrowseOptions): Promise<Result<void>>;
|
|
11
|
+
/**
|
|
12
|
+
* Starts the server using ts-res-browser CLI directly
|
|
13
|
+
*/
|
|
14
|
+
private _startServer;
|
|
15
|
+
/**
|
|
16
|
+
* Opens the browser to the specified URL
|
|
17
|
+
*/
|
|
18
|
+
private _openBrowser;
|
|
19
|
+
/**
|
|
20
|
+
* Builds the URL with query parameters based on options
|
|
21
|
+
*/
|
|
22
|
+
private _buildUrl;
|
|
23
|
+
/**
|
|
24
|
+
* Determines if a ZIP archive should be created based on the options
|
|
25
|
+
*/
|
|
26
|
+
private _shouldCreateZip;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a ZIP archive containing the input and config files
|
|
29
|
+
*/
|
|
30
|
+
private _createZipArchive;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=simpleBrowserLauncher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simpleBrowserLauncher.d.ts","sourceRoot":"","sources":["../src/simpleBrowserLauncher.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAmGnE;;OAEG;YACW,YAAY;IAgC1B;;OAEG;YACW,YAAY;IAkB1B;;OAEG;IACH,OAAO,CAAC,SAAS;IAsDjB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;YACW,iBAAiB;CAYhC"}
|