@fgv/ts-res-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.eslintrc.js +9 -0
  2. package/.rush/temp/chunked-rush-logs/ts-res-cli.build.chunks.jsonl +6 -0
  3. package/.rush/temp/operation/build/log-chunks.jsonl +6 -0
  4. package/.rush/temp/operation/build/state.json +3 -0
  5. package/.rush/temp/shrinkwrap-deps.json +651 -0
  6. package/README.md +197 -0
  7. package/bin/ts-res-compile.js +40 -0
  8. package/config/jest.config.json +9 -0
  9. package/config/rig.json +16 -0
  10. package/lib/cli.d.ts +36 -0
  11. package/lib/cli.d.ts.map +1 -0
  12. package/lib/cli.js +464 -0
  13. package/lib/cli.js.map +1 -0
  14. package/lib/compiler.d.ts +86 -0
  15. package/lib/compiler.d.ts.map +1 -0
  16. package/lib/compiler.js +415 -0
  17. package/lib/compiler.js.map +1 -0
  18. package/lib/defaultConfiguration.d.ts +7 -0
  19. package/lib/defaultConfiguration.d.ts.map +1 -0
  20. package/lib/defaultConfiguration.js +79 -0
  21. package/lib/defaultConfiguration.js.map +1 -0
  22. package/lib/index.d.ts +4 -0
  23. package/lib/index.d.ts.map +1 -0
  24. package/lib/index.js +41 -0
  25. package/lib/index.js.map +1 -0
  26. package/lib/options.d.ts +66 -0
  27. package/lib/options.d.ts.map +1 -0
  28. package/lib/options.js +24 -0
  29. package/lib/options.js.map +1 -0
  30. package/package.json +59 -0
  31. package/src/cli.ts +607 -0
  32. package/src/compiler.ts +504 -0
  33. package/src/defaultConfiguration.ts +78 -0
  34. package/src/index.ts +25 -0
  35. package/src/options.ts +101 -0
  36. package/test/data/resource-collection.json +28 -0
  37. package/test/data/sample-resources.json +41 -0
  38. package/test/integration/cli-configuration.test.ts +419 -0
  39. package/test/integration/cli-context-filter-working.test.ts +341 -0
  40. package/test/integration/cli-integration.test.ts +533 -0
  41. package/test/unit/cli.test.ts +413 -0
  42. package/test/unit/compiler.test.ts +1084 -0
  43. package/tsconfig.json +8 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Output format options for resource compilation
3
+ */
4
+ export type OutputFormat = 'compiled' | 'source' | 'js' | 'ts' | 'binary';
5
+ /**
6
+ * Options for resource compilation
7
+ */
8
+ export interface ICompileOptions {
9
+ /**
10
+ * Input file or directory path
11
+ */
12
+ input: string;
13
+ /**
14
+ * Output file path
15
+ */
16
+ output: string;
17
+ /**
18
+ * System configuration file path (JSON file in ISystemConfiguration format)
19
+ */
20
+ config?: string;
21
+ /**
22
+ * Context filter token (pipe-separated qualifier=value pairs, e.g., 'language=en-US|territory=US')
23
+ */
24
+ contextFilter?: string;
25
+ /**
26
+ * Qualifier default values token (pipe-separated qualifier=value pairs, e.g., 'language=en-US,en-CA|territory=US')
27
+ */
28
+ qualifierDefaults?: string;
29
+ /**
30
+ * Output format
31
+ */
32
+ format: OutputFormat;
33
+ /**
34
+ * Whether to include debug information
35
+ */
36
+ debug: boolean;
37
+ /**
38
+ * Whether to run in verbose mode
39
+ */
40
+ verbose: boolean;
41
+ /**
42
+ * Whether to run in quiet mode
43
+ */
44
+ quiet: boolean;
45
+ /**
46
+ * Whether to validate resources during compilation
47
+ */
48
+ validate: boolean;
49
+ /**
50
+ * Whether to include resource metadata in output
51
+ */
52
+ includeMetadata: boolean;
53
+ /**
54
+ * Resource type filter (e.g., 'json,other')
55
+ */
56
+ resourceTypes?: string;
57
+ /**
58
+ * Maximum distance for language matching
59
+ */
60
+ maxDistance?: number;
61
+ /**
62
+ * Whether to reduce qualifiers when filtering by context
63
+ */
64
+ reduceQualifiers?: boolean;
65
+ }
66
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;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,MAAM,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
package/lib/options.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2025 Erik Fortune
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in all
13
+ * copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ * SOFTWARE.
22
+ */
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG","sourcesContent":["/*\r\n * Copyright (c) 2025 Erik Fortune\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all\r\n * copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\n\r\n/**\r\n * Output format options for resource compilation\r\n */\r\nexport type OutputFormat = 'compiled' | 'source' | 'js' | 'ts' | 'binary';\r\n\r\n/**\r\n * Options for resource compilation\r\n */\r\nexport interface ICompileOptions {\r\n /**\r\n * Input file or directory path\r\n */\r\n input: string;\r\n\r\n /**\r\n * Output file path\r\n */\r\n output: string;\r\n\r\n /**\r\n * System configuration file path (JSON file in ISystemConfiguration format)\r\n */\r\n config?: string;\r\n\r\n /**\r\n * Context filter token (pipe-separated qualifier=value pairs, e.g., 'language=en-US|territory=US')\r\n */\r\n contextFilter?: string;\r\n\r\n /**\r\n * Qualifier default values token (pipe-separated qualifier=value pairs, e.g., 'language=en-US,en-CA|territory=US')\r\n */\r\n qualifierDefaults?: string;\r\n\r\n /**\r\n * Output format\r\n */\r\n format: OutputFormat;\r\n\r\n /**\r\n * Whether to include debug information\r\n */\r\n debug: boolean;\r\n\r\n /**\r\n * Whether to run in verbose mode\r\n */\r\n verbose: boolean;\r\n\r\n /**\r\n * Whether to run in quiet mode\r\n */\r\n quiet: boolean;\r\n\r\n /**\r\n * Whether to validate resources during compilation\r\n */\r\n validate: boolean;\r\n\r\n /**\r\n * Whether to include resource metadata in output\r\n */\r\n includeMetadata: boolean;\r\n\r\n /**\r\n * Resource type filter (e.g., 'json,other')\r\n */\r\n resourceTypes?: string;\r\n\r\n /**\r\n * Maximum distance for language matching\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Whether to reduce qualifiers when filtering by context\r\n */\r\n reduceQualifiers?: boolean;\r\n}\r\n"]}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@fgv/ts-res-cli",
3
+ "version": "1.0.0",
4
+ "description": "Command-line interface for ts-res resource compilation and management",
5
+ "main": "lib/index.js",
6
+ "bin": {
7
+ "ts-res-compile": "bin/ts-res-compile.js"
8
+ },
9
+ "keywords": [
10
+ "typescript",
11
+ "resources",
12
+ "internationalization",
13
+ "localization",
14
+ "cli",
15
+ "tool"
16
+ ],
17
+ "author": "Erik Fortune",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "commander": "^11.0.0",
21
+ "@fgv/ts-res": "5.0.0-0",
22
+ "@fgv/ts-utils": "5.0.0-0",
23
+ "@fgv/ts-extras": "5.0.0-0",
24
+ "@fgv/ts-json-base": "5.0.0-0",
25
+ "@fgv/ts-json": "5.0.0-0"
26
+ },
27
+ "devDependencies": {
28
+ "@rushstack/heft": "~0.74.0",
29
+ "@rushstack/heft-node-rig": "~2.9.0",
30
+ "@rushstack/eslint-config": "~4.4.0",
31
+ "@types/heft-jest": "1.0.6",
32
+ "@types/jest": "^29.5.14",
33
+ "@types/node": "^20.14.9",
34
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
35
+ "@typescript-eslint/parser": "^7.14.1",
36
+ "eslint": "^8.57.0",
37
+ "jest": "^29.7.0",
38
+ "ts-jest": "^29.4.0",
39
+ "typescript": "^5.7.3",
40
+ "@fgv/ts-utils-jest": "5.0.0-0"
41
+ },
42
+ "peerDependencies": {
43
+ "typescript": "^5.7.3"
44
+ },
45
+ "scripts": {
46
+ "build": "heft build --clean",
47
+ "test": "heft test --clean",
48
+ "build-all": "rushx build && rushx build-docs",
49
+ "coverage": "heft test --clean --coverage",
50
+ "clean": "heft clean",
51
+ "lint": "eslint src --ext .ts",
52
+ "fixlint": "eslint src --ext .ts --fix",
53
+ "build-docs": "api-documenter markdown --input-folder ./temp --output-folder ./docs",
54
+ "test-handles": "rushx test --detectOpenHandles",
55
+ "clean-jest": "rushx test --clearCache",
56
+ "build-samples": "node bin/ts-res-compile.js compile -i src/test/data/sample-resources.json -o temp/sample-output.json --include-metadata",
57
+ "build-samples-all": "npm run build-samples && node bin/ts-res-compile.js compile -i src/test/data/resource-collection.json -o temp/collection-output.json --include-metadata && node bin/ts-res-compile.js compile -i src/test/data/sample-resources.json -o temp/sample-output.js -f js && node bin/ts-res-compile.js compile -i src/test/data/sample-resources.json -o temp/sample-output.ts -f ts"
58
+ }
59
+ }