@l10nmonster/cli 3.1.0 → 3.1.1
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/CHANGELOG.md +22 -0
- package/index.js +91 -4
- package/interfaces.d.ts +15 -0
- package/package.json +4 -3
- package/tsconfig.json +18 -0
- package/.releaserc.json +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## @l10nmonster/cli [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/cli@3.1.0...@l10nmonster/cli@3.1.1) (2025-12-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
|
|
7
|
+
|
|
8
|
+
## @l10nmonster/cli [3.1.1](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/cli@3.1.0...@l10nmonster/cli@3.1.1) (2025-12-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* Improve type definitions and checks ([826b412](https://public-github/l10nmonster/l10nmonster/commit/826b412f0f7e761d404165a243b0c2b26c416ac1))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Dependencies
|
|
20
|
+
|
|
21
|
+
* **@l10nmonster/core:** upgraded to 3.1.1
|
|
22
|
+
|
|
1
23
|
# @l10nmonster/cli [3.1.0](https://public-github/l10nmonster/l10nmonster/compare/@l10nmonster/cli@3.0.0...@l10nmonster/cli@3.1.0) (2025-12-20)
|
|
2
24
|
|
|
3
25
|
|
package/index.js
CHANGED
|
@@ -1,10 +1,96 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
|
|
3
3
|
import { Command, Argument, Option, InvalidArgumentError } from 'commander';
|
|
4
|
-
|
|
4
|
+
import { existsSync } from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { l10nMonsterVersion } from '@l10nmonster/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Find l10nmonster.config.mjs by walking up the directory tree.
|
|
10
|
+
* @param {string} [startDir] - Directory to start searching from (defaults to cwd)
|
|
11
|
+
* @returns {string|null} - Path to config file or null if not found
|
|
12
|
+
*/
|
|
13
|
+
export function findConfigFile(startDir = process.cwd()) {
|
|
14
|
+
let currentDir = path.resolve(startDir);
|
|
15
|
+
const configFileName = 'l10nmonster.config.mjs';
|
|
16
|
+
|
|
17
|
+
while (true) {
|
|
18
|
+
const configPath = path.join(currentDir, configFileName);
|
|
19
|
+
if (existsSync(configPath)) {
|
|
20
|
+
return configPath;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const parentDir = path.dirname(currentDir);
|
|
24
|
+
if (parentDir === currentDir) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
currentDir = parentDir;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Run the CLI with automatic config discovery.
|
|
35
|
+
* @param {Object} [options] - Options for running the CLI
|
|
36
|
+
* @param {Array} [options.extraActions] - Additional actions to register
|
|
37
|
+
* @returns {Promise<void>}
|
|
38
|
+
*/
|
|
39
|
+
export async function runCLI({ extraActions = [] } = {}) {
|
|
40
|
+
// Global unhandled promise rejection handler
|
|
41
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
42
|
+
console.error('Unhandled Promise Rejection detected:');
|
|
43
|
+
console.error('Promise:', promise);
|
|
44
|
+
console.error('Reason:', reason);
|
|
45
|
+
if (reason instanceof Error && reason.stack) {
|
|
46
|
+
console.error('Stack trace:', reason.stack);
|
|
47
|
+
}
|
|
48
|
+
console.error('Exiting due to unhandled promise rejection...');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Global uncaught exception handler
|
|
53
|
+
process.on('uncaughtException', (error) => {
|
|
54
|
+
console.error('Uncaught Exception:', error);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Handle --help and --version before requiring config
|
|
59
|
+
const args = process.argv.slice(2);
|
|
60
|
+
if (args.length === 0 || args.includes('--help') || args.includes('-h') || args.includes('--version')) {
|
|
61
|
+
const helpCLI = new Command();
|
|
62
|
+
helpCLI
|
|
63
|
+
.name('l10n')
|
|
64
|
+
.version(l10nMonsterVersion, '--version', 'output the current version number')
|
|
65
|
+
.description('Continuous localization for the rest of us.\n\nRun from a directory containing l10nmonster.config.mjs to see available commands.');
|
|
66
|
+
helpCLI.parse();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
const configPath = findConfigFile();
|
|
72
|
+
if (!configPath) {
|
|
73
|
+
console.error('Error: Could not find l10nmonster.config.mjs in current directory or any parent directory.');
|
|
74
|
+
console.error('Please ensure the config file exists in your project root or current working directory.');
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const config = await import(configPath);
|
|
79
|
+
let monsterConfig = config.default;
|
|
80
|
+
|
|
81
|
+
// Add any extra actions
|
|
82
|
+
for (const action of extraActions) {
|
|
83
|
+
monsterConfig = monsterConfig.action(action);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line no-use-before-define
|
|
87
|
+
await runMonsterCLI(monsterConfig);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error('Error running l10nmonster CLI:');
|
|
90
|
+
console.error(error.stack || error);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
8
94
|
|
|
9
95
|
function intOptionParser(value) {
|
|
10
96
|
const parsedValue = parseInt(value, 10);
|
|
@@ -49,11 +135,12 @@ function configureCommand(cmd, Action, l10nRunner) {
|
|
|
49
135
|
});
|
|
50
136
|
}
|
|
51
137
|
|
|
138
|
+
/** @type {import('./interfaces.js').RunMonsterCLI} */
|
|
52
139
|
export default async function runMonsterCLI(monsterConfig, cliCommand) {
|
|
53
140
|
const monsterCLI = new Command();
|
|
54
141
|
monsterCLI
|
|
55
142
|
.name('l10n')
|
|
56
|
-
.version(
|
|
143
|
+
.version(l10nMonsterVersion, '--version', 'output the current version number')
|
|
57
144
|
.description('Continuous localization for the rest of us.')
|
|
58
145
|
.option('-v, --verbose [level]', '0=error, 1=warning, 2=info, 3=verbose', intOptionParser)
|
|
59
146
|
.option('--regression', 'keep variables constant during regression testing');
|
package/interfaces.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central type definitions for @l10nmonster/cli
|
|
3
|
+
* Re-exports L10nAction as CLIAction for CLI-specific use.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Re-export L10nAction from core as CLIAction for backwards compatibility
|
|
7
|
+
export { ActionHelp, L10nAction as CLIAction } from '@l10nmonster/core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Function signature for running the L10n Monster CLI.
|
|
11
|
+
*/
|
|
12
|
+
export type RunMonsterCLI = (
|
|
13
|
+
monsterConfig: any,
|
|
14
|
+
cliCommand?: string | string[]
|
|
15
|
+
) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@l10nmonster/cli",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "Continuous localization for the rest of us",
|
|
5
5
|
"bin": {
|
|
6
6
|
"l10n": "l10n.mjs"
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"translation-files"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "node --test"
|
|
18
|
+
"test": "node --test",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
19
20
|
},
|
|
20
21
|
"author": "Diego Lagunas",
|
|
21
22
|
"license": "MIT",
|
|
@@ -28,6 +29,6 @@
|
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
31
|
"commander": "^14",
|
|
31
|
-
"@l10nmonster/core": "3.1.
|
|
32
|
+
"@l10nmonster/core": "3.1.1"
|
|
32
33
|
}
|
|
33
34
|
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.base.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"*.js",
|
|
5
|
+
"**/*.js"
|
|
6
|
+
],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"node_modules",
|
|
9
|
+
"**/node_modules",
|
|
10
|
+
"test/**",
|
|
11
|
+
"tests/**",
|
|
12
|
+
"**/*.test.js",
|
|
13
|
+
"**/*.spec.js",
|
|
14
|
+
"dist/**",
|
|
15
|
+
"ui/**",
|
|
16
|
+
"types/**"
|
|
17
|
+
]
|
|
18
|
+
}
|
package/.releaserc.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": [
|
|
3
|
-
"main",
|
|
4
|
-
{
|
|
5
|
-
"name": "next",
|
|
6
|
-
"prerelease": "alpha"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"name": "beta",
|
|
10
|
-
"prerelease": "beta"
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"tagFormat": "@l10nmonster/cli@${version}",
|
|
14
|
-
"plugins": [
|
|
15
|
-
"@semantic-release/commit-analyzer",
|
|
16
|
-
"@semantic-release/release-notes-generator",
|
|
17
|
-
{
|
|
18
|
-
"path": "@semantic-release/changelog",
|
|
19
|
-
"changelogFile": "CHANGELOG.md"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "@semantic-release/npm",
|
|
23
|
-
"npmPublish": false
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"path": "@semantic-release/git",
|
|
27
|
-
"assets": ["CHANGELOG.md", "package.json"],
|
|
28
|
-
"message": "chore(release): @l10nmonster/cli@${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
29
|
-
}
|
|
30
|
-
]
|
|
31
|
-
}
|