@l10nmonster/cli 1.0.5 → 3.0.0-alpha.10

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/package.json CHANGED
@@ -1,20 +1,12 @@
1
1
  {
2
2
  "name": "@l10nmonster/cli",
3
- "version": "1.0.5",
3
+ "version": "3.0.0-alpha.10",
4
4
  "description": "Continuous localization for the rest of us",
5
5
  "bin": {
6
- "l10n": "l10n.cjs"
6
+ "l10n": "l10n.mjs"
7
7
  },
8
- "exports": {
9
- "import": "./l10nCommands.js",
10
- "require": "./out/l10nCommands.cjs"
11
- },
12
- "main": "out/l10nCommands.cjs",
13
8
  "type": "module",
14
- "scripts": {
15
- "esbuild": "esbuild l10nCommands.js --bundle --external:@l10nmonster/core --external:@l10nmonster/helpers --external:commander --external:winston --outfile=out/l10nCommands.cjs --format=cjs --platform=node --target=node18 --sourcemap",
16
- "esbuild-watch": "npm run esbuild -- --watch"
17
- },
9
+ "main": "index.js",
18
10
  "repository": {
19
11
  "type": "git",
20
12
  "url": "git+https://github.com/l10nmonster/l10nmonster.git"
@@ -26,6 +18,9 @@
26
18
  "globalization",
27
19
  "translation-files"
28
20
  ],
21
+ "scripts": {
22
+ "test": "node --test"
23
+ },
29
24
  "author": "Diego Lagunas",
30
25
  "license": "MIT",
31
26
  "bugs": {
@@ -33,18 +28,10 @@
33
28
  },
34
29
  "homepage": "https://github.com/l10nmonster/l10nmonster#readme",
35
30
  "engines": {
36
- "node": ">=18"
31
+ "node": ">=22.11.0"
37
32
  },
38
33
  "dependencies": {
39
- "commander": "^12",
40
- "winston": "^3.7.2"
41
- },
42
- "peerDependencies": {
43
- "@l10nmonster/core": "^1.0.6",
44
- "@l10nmonster/helpers": "^1"
45
- },
46
- "devDependencies": {
47
- "esbuild": "latest",
48
- "eslint": "latest"
34
+ "commander": "^14",
35
+ "@l10nmonster/core": "^3.0.0-alpha.0"
49
36
  }
50
37
  }
package/l10n.cjs DELETED
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable no-underscore-dangle */
3
-
4
- const path = require('path');
5
- const { existsSync } = require('fs');
6
- const { Command, Argument, InvalidArgumentError } = require('commander');
7
- const { builtInCmds, runL10nMonster } = require('./out/l10nCommands.cjs');
8
-
9
- /* eslint-disable no-invalid-this */
10
-
11
- // eslint-disable-next-line no-unused-vars
12
- function intOptionParser(value, _dummyPrevious) {
13
- const parsedValue = parseInt(value, 10);
14
- if (isNaN(parsedValue)) {
15
- throw new InvalidArgumentError('Not an integer');
16
- }
17
- return parsedValue;
18
- }
19
-
20
- async function runMonsterCLI(monsterConfigPath) {
21
- const monsterCLI = new Command();
22
- monsterCLI
23
- .name('l10n')
24
- .version('0.1.0', '--version', 'output the current version number')
25
- .description('Continuous localization for the rest of us.')
26
- .option('-v, --verbose [level]', '0=error, 1=warning, 2=info, 3=verbose', intOptionParser)
27
- .option('-p, --prj <prj1,...>', 'limit source to specified projects')
28
- .option('--arg <string>', 'optional config constructor argument')
29
- .option('--regression', 'keep variables constant during regression testing');
30
- try {
31
- const actionHandler = async function actionHandler() {
32
- const options = this.opts();
33
- // Need to hack into the guts of commander as it doesn't seem to expose argument names
34
- const args = Object.fromEntries(this._args.map((arg, idx) => [
35
- arg._name,
36
- arg.variadic ? this.args.slice(idx) : this.args[idx]
37
- ]));
38
- await runL10nMonster(monsterConfigPath, monsterCLI.opts(), async l10n => {
39
- await l10n[this.name()]({ ...options, ...args });
40
- });
41
- };
42
- const Config = require(monsterConfigPath);
43
- [ ...builtInCmds, ...(Config.extensionCmds ?? []) ]
44
- .forEach(Cmd => {
45
- const help = Cmd.help;
46
- const cmd = monsterCLI.command(Cmd.name)
47
- .description(help.description)
48
- .action(actionHandler);
49
- help.options && help.options.forEach(opt => cmd.option(...opt));
50
- help.requiredOptions && help.requiredOptions.forEach(opt => cmd.requiredOption(...opt));
51
- help.arguments && help.arguments.forEach(([ arg, desc, choices]) => {
52
- if (choices) {
53
- cmd.addArgument(new Argument(arg, desc).choices(choices));
54
- } else {
55
- cmd.argument(arg, desc);
56
- }
57
- });
58
- });
59
- await monsterCLI.parseAsync();
60
- } catch(e) {
61
- console.error(`Unable to run: ${e.stack || e}`);
62
- process.exit(1);
63
- }
64
- }
65
-
66
- function findConfig() {
67
- let baseDir = path.resolve('.'),
68
- previousDir = null;
69
- while (baseDir !== previousDir) {
70
- const configPath = path.join(baseDir, 'l10nmonster.cjs');
71
- if (existsSync(configPath)) {
72
- return configPath;
73
- }
74
- previousDir = baseDir;
75
- baseDir = path.resolve(baseDir, '..');
76
- }
77
- return '';
78
- }
79
-
80
- (async () => {
81
- const cfg = findConfig();
82
- if (cfg) {
83
- await runMonsterCLI(cfg);
84
- } else {
85
- console.error(`Unable to run: couldn't find an l10nmonster.cjs file!`);
86
- process.exit(1);
87
- }
88
- })();