i18next-cli 1.80.5 → 1.80.7

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 (36) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/cli.js +1 -1
  3. package/dist/cjs/config.js +2 -6
  4. package/dist/cjs/extractor/core/ast-visitors.js +13 -6
  5. package/dist/cjs/extractor/parsers/expression-resolver.js +93 -25
  6. package/dist/cjs/extractor/parsers/scope-manager.js +9 -5
  7. package/dist/cjs/init.js +2 -6
  8. package/dist/cjs/instrumenter/core/instrumenter.js +5 -9
  9. package/dist/cjs/localize/localize.js +6 -6
  10. package/dist/cjs/locize.js +21 -21
  11. package/dist/cjs/status.js +9 -9
  12. package/dist/cjs/utils/locize-onboarding.js +10 -10
  13. package/dist/cjs/utils/prompt.js +33 -0
  14. package/dist/cjs/utils/wrap-ora.js +12 -18
  15. package/dist/esm/cli.js +1 -1
  16. package/dist/esm/config.js +2 -2
  17. package/dist/esm/extractor/core/ast-visitors.js +13 -6
  18. package/dist/esm/extractor/parsers/expression-resolver.js +93 -26
  19. package/dist/esm/extractor/parsers/scope-manager.js +9 -5
  20. package/dist/esm/init.js +2 -2
  21. package/dist/esm/instrumenter/core/instrumenter.js +5 -5
  22. package/dist/esm/localize/localize.js +5 -5
  23. package/dist/esm/locize.js +19 -19
  24. package/dist/esm/status.js +8 -8
  25. package/dist/esm/utils/locize-onboarding.js +9 -9
  26. package/dist/esm/utils/prompt.js +24 -0
  27. package/dist/esm/utils/wrap-ora.js +11 -17
  28. package/package.json +8 -5
  29. package/types/extractor/core/ast-visitors.d.ts.map +1 -1
  30. package/types/extractor/parsers/expression-resolver.d.ts +17 -0
  31. package/types/extractor/parsers/expression-resolver.d.ts.map +1 -1
  32. package/types/extractor/parsers/scope-manager.d.ts +1 -0
  33. package/types/extractor/parsers/scope-manager.d.ts.map +1 -1
  34. package/types/utils/prompt.d.ts +8 -0
  35. package/types/utils/prompt.d.ts.map +1 -0
  36. package/types/utils/wrap-ora.d.ts +1 -1
package/README.md CHANGED
@@ -4,6 +4,7 @@ A unified, high-performance i18next CLI toolchain, powered by SWC.
4
4
 
5
5
  [![Tests](https://github.com/i18next/i18next-cli/workflows/node/badge.svg)](https://github.com/i18next/i18next-cli/actions?query=workflow%3Anode)
6
6
  [![npm version](https://img.shields.io/npm/v/i18next-cli.svg?style=flat-square)](https://www.npmjs.com/package/i18next-cli)
7
+ [![Socket Badge](https://badge.socket.dev/npm/package/i18next-cli)](https://socket.dev/npm/package/i18next-cli)
7
8
 
8
9
  ---
9
10
 
package/dist/cjs/cli.js CHANGED
@@ -39,7 +39,7 @@ const program = new commander.Command();
39
39
  program
40
40
  .name('i18next-cli')
41
41
  .description('A unified, high-performance i18next CLI.')
42
- .version('1.80.5') // This string is replaced with the actual version at build time by rollup
42
+ .version('1.80.7') // This string is replaced with the actual version at build time by rollup
43
43
  .addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
44
44
  // new: global config override option
45
45
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
@@ -5,15 +5,11 @@ var node_url = require('node:url');
5
5
  var promises = require('node:fs/promises');
6
6
  var jiti = require('jiti');
7
7
  var jsoncParser = require('jsonc-parser');
8
- var inquirer = require('inquirer');
8
+ var prompt = require('./utils/prompt.js');
9
9
  var node_util = require('node:util');
10
10
  var init = require('./init.js');
11
11
  var logger = require('./utils/logger.js');
12
12
 
13
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
-
15
- var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
16
-
17
13
  /**
18
14
  * List of supported configuration file names in order of precedence
19
15
  */
@@ -132,7 +128,7 @@ async function ensureConfig(configPath, logger$1 = new logger.ConsoleLogger()) {
132
128
  return config;
133
129
  }
134
130
  // No config found, so we prompt the user.
135
- const { shouldInit } = await inquirer__default.default.prompt([{
131
+ const { shouldInit } = await prompt.prompt([{
136
132
  type: 'confirm',
137
133
  name: 'shouldInit',
138
134
  message: node_util.styleText('yellow', 'Configuration file not found. Would you like to create one now?'),
@@ -100,6 +100,7 @@ class ASTVisitors {
100
100
  // `useTranslation(ns)` where `ns` is a param typed `'a' | 'b'` → first member
101
101
  // (same rule as `TFunction<'a' | 'b'>`).
102
102
  this.scopeManager.identifierFallback = (name) => this.expressionResolver.getVariableValues(name)?.[0];
103
+ this.scopeManager.isParameter = (name) => this.expressionResolver.isParameter(name);
103
104
  // use shared resolver when provided so captured enums/objects are visible across files
104
105
  this.expressionResolver = expressionResolver$1 ?? new expressionResolver.ExpressionResolver(this.hooks);
105
106
  this.callExpressionHandler = new callExpressionHandler.CallExpressionHandler(config, pluginContext, logger, this.expressionResolver, () => this.getCurrentFile(), () => this.getCurrentCode(), (name) => this.scopeManager.resolveSimpleStringIdentifier(name));
@@ -136,6 +137,8 @@ class ASTVisitors {
136
137
  _walkForConstants(node) {
137
138
  if (!node || typeof node !== 'object')
138
139
  return;
140
+ // Like `walk`: a function's parameters hide the values declared under their names
141
+ const leaveParameters = Array.isArray(node.params) ? this.expressionResolver.enterParameters(node) : undefined;
139
142
  switch (node.type) {
140
143
  case 'VariableDeclarator':
141
144
  // String constants → ScopeManager.sharedConstants
@@ -193,6 +196,7 @@ class ASTVisitors {
193
196
  this._walkForConstants(child);
194
197
  }
195
198
  }
199
+ leaveParameters?.();
196
200
  }
197
201
  /**
198
202
  * Main entry point for AST traversal.
@@ -261,6 +265,9 @@ class ASTVisitors {
261
265
  }
262
266
  }
263
267
  }
268
+ // Any function, also a method or constructor: its parameters hide the values declared
269
+ // under their names while its body is walked (#316)
270
+ const leaveParameters = Array.isArray(node.params) ? this.expressionResolver.enterParameters(node) : undefined;
264
271
  // ENTER SCOPE for functions
265
272
  // Accept many SWC/TS AST variants for function-like nodes (declarations, expressions, arrow functions)
266
273
  if (node.type === 'Function' ||
@@ -649,6 +656,7 @@ class ASTVisitors {
649
656
  // --- END RECURSION ---
650
657
  // Remove temporary callback param binding if one was injected for this node
651
658
  arrayCallbackCleanup?.();
659
+ leaveParameters?.();
652
660
  // LEAVE SCOPE for functions
653
661
  if (isNewScope) {
654
662
  // Remove temporary parameter type bindings
@@ -882,12 +890,11 @@ class ASTVisitors {
882
890
  // The single argument to Object.keys/values must be a known identifier
883
891
  const mapArg = this.expressionResolver.unwrapNamespace(obj.arguments?.[0]?.expression);
884
892
  if (mapArg?.type === 'Identifier') {
885
- const mapEntry = this.expressionResolver.getObjectMap(mapArg.value);
886
- if (mapEntry) {
887
- const values = isKeys ? Object.keys(mapEntry) : Object.values(mapEntry);
888
- if (values.length > 0) {
889
- return this.extractCallbackParam(node, values, elementParamIndex);
890
- }
893
+ const values = isKeys
894
+ ? this.expressionResolver.getObjectKeys(mapArg.value)
895
+ : Object.values(this.expressionResolver.getObjectMap(mapArg.value) ?? {});
896
+ if (values?.length) {
897
+ return this.extractCallbackParam(node, values, elementParamIndex);
891
898
  }
892
899
  }
893
900
  }
@@ -62,6 +62,31 @@ const memberByKey = (members, key) => {
62
62
  }
63
63
  return index.get(key);
64
64
  };
65
+ // The names a function parameter binds: `options`, `{ a, b: [c] } = {}`, `...rest`, `private d`
66
+ const bindingNames = (pat) => {
67
+ switch (pat?.type) {
68
+ case 'Identifier': return [pat.value];
69
+ case 'Parameter': return bindingNames(pat.pat);
70
+ case 'TsParameterProperty': return bindingNames(pat.param);
71
+ case 'AssignmentPattern': return bindingNames(pat.left);
72
+ case 'RestElement': return bindingNames(pat.argument);
73
+ case 'ArrayPattern': return pat.elements.flatMap(bindingNames);
74
+ case 'ObjectPattern': return pat.properties.flatMap((p) => p.type === 'AssignmentPatternProperty' ? [p.key.value] : bindingNames(p.value ?? p.argument));
75
+ default: return [];
76
+ }
77
+ };
78
+ // A table of values (variables, object maps, enums, functions). Inside a function, a parameter
79
+ // hides the entry of its name: `options` there is never an `options` declared elsewhere (#316)
80
+ class ValueTable extends Map {
81
+ scope;
82
+ constructor(scope) {
83
+ super();
84
+ this.scope = scope;
85
+ }
86
+ get(name) {
87
+ return this.scope.isParameter(name) ? undefined : super.get(name);
88
+ }
89
+ }
65
90
  // `/src/api/github-api.ts`, `.d.ts`, or an import of `./github-api.js` -> `/src/api/github-api`
66
91
  const moduleKey = (path) => path.replace(/(\.d)?\.[cm]?[jt]sx?$/, '');
67
92
  /**
@@ -73,11 +98,16 @@ const moduleKey = (path) => path.replace(/(\.d)?\.[cm]?[jt]sx?$/, '');
73
98
  */
74
99
  class ModuleTable extends Map {
75
100
  scope;
76
- constructor(scope) {
101
+ holdsValues;
102
+ constructor(scope, holdsValues = false) {
77
103
  super();
78
104
  this.scope = scope;
105
+ this.holdsValues = holdsValues;
79
106
  }
80
107
  get(name) {
108
+ // Like a ValueTable: a parameter hides the value declared under its name in any file
109
+ if (this.holdsValues && this.scope.isParameter(name))
110
+ return undefined;
81
111
  for (const key of this.scope.keysOf(name)) {
82
112
  const value = super.get(key);
83
113
  if (value !== undefined)
@@ -131,18 +161,22 @@ class ExpressionResolver {
131
161
  // Maps variableName -> either:
132
162
  // - string[] (possible string values)
133
163
  // - Record<string, string> (object of static string properties)
134
- variableTable = new Map();
164
+ variableTable = new ValueTable(this);
135
165
  // Shared (cross-file) table for enums / exported object maps that should persist
136
- sharedEnumTable = new ModuleTable(this);
166
+ sharedEnumTable = new ModuleTable(this, true);
137
167
  // Per-file table for type aliases: Maps typeName -> string[]
138
168
  // e.g. `type ChangeType = 'all' | 'next' | 'this'` -> { ChangeType: ['all', 'next', 'this'] }
139
169
  typeAliasTable = new Map();
140
170
  // Shared (cross-file) table for string-array constants (e.g. `as const` arrays).
141
171
  // Persists across resetFileSymbols() so exported arrays are visible to importers.
142
- sharedVariableTable = new ModuleTable(this);
172
+ sharedVariableTable = new ModuleTable(this, true);
143
173
  // Shared (cross-file) table for as-const object maps, `export const LABELS = { … } as const`,
144
174
  // so `LABELS.save` and `Object.keys(LABELS)` resolve in importing files.
145
- sharedObjectMapTable = new ModuleTable(this);
175
+ sharedObjectMapTable = new ModuleTable(this, true);
176
+ // Shared (cross-file) literal keys of every object declared as `const MAP = { … }`, whatever
177
+ // its values are: the map tables above only hold string values, `keyof typeof MAP` and
178
+ // `Object.keys(MAP)` need all keys (#317).
179
+ sharedObjectKeysTable = new ModuleTable(this, true);
146
180
  // Shared (cross-file) table for type aliases — populated alongside typeAliasTable.
147
181
  // Persists across resetFileSymbols() so exported type aliases are visible to importers.
148
182
  sharedTypeAliasTable = new ModuleTable(this);
@@ -150,7 +184,7 @@ class ExpressionResolver {
150
184
  // both explicit return-type annotations and body-inferred return values so
151
185
  // that `t(fn())` / `const x = fn(); t(\`...${x}...\`)` work across files.
152
186
  // Persists across resetFileSymbols() just like the other shared tables.
153
- sharedFunctionReturnTable = new ModuleTable(this);
187
+ sharedFunctionReturnTable = new ModuleTable(this, true);
154
188
  // Temporary per-scope variable overrides, used to inject .map() / .forEach()
155
189
  // callback parameters while the callback body is being walked.
156
190
  temporaryVariables = new Map();
@@ -181,13 +215,13 @@ class ExpressionResolver {
181
215
  typeParamBindings = new Map();
182
216
  // Shared (cross-file) member maps of functions returning an object type,
183
217
  // e.g. `const getAnimal = (): Animal => …` -> { getAnimal: { type: ['DUCK', 'DOG'] } }
184
- sharedFunctionReturnMembers = new ModuleTable(this);
218
+ sharedFunctionReturnMembers = new ModuleTable(this, true);
185
219
  // Per-file identifiers holding an object type, from their annotation or from the
186
220
  // function they were initialised by: `const animal = getAnimal()` -> { animal: { type: [...] } }
187
- objectVariables = new Map();
221
+ objectVariables = new ValueTable(this);
188
222
  // Per-file object literals by variable, so `const params = { count }; t('key', params)`
189
223
  // reads its options like an inline object (#307)
190
- objectLiterals = new Map();
224
+ objectLiterals = new ValueTable(this);
191
225
  // Set while the pre-scan runs. Captures that read other declarations queue a
192
226
  // replay here, because what they read may be declared in a file scanned later.
193
227
  recording = false;
@@ -209,6 +243,8 @@ class ExpressionResolver {
209
243
  fileNamespaces = new Map();
210
244
  // module -> the variables it declares, which shadow the same names declared in other files
211
245
  fileVariables = new Map();
246
+ // The parameters of the functions being read, innermost last
247
+ parameters = [];
212
248
  // tsconfig `paths`, `@api` -> `/abs/src/api`
213
249
  pathAliases = {};
214
250
  constructor(hooks) {
@@ -251,6 +287,19 @@ class ExpressionResolver {
251
287
  keys.push(name);
252
288
  return keys;
253
289
  }
290
+ // ValueTable / ModuleTable: whether `name` is a parameter of a function being read
291
+ isParameter(name) {
292
+ return this.parameters.includes(name);
293
+ }
294
+ /**
295
+ * Hide the values declared under the names of `fn`'s parameters while its body is read.
296
+ * Call the returned function when leaving it.
297
+ */
298
+ enterParameters(fn) {
299
+ const names = (fn?.params ?? []).flatMap(bindingNames);
300
+ this.parameters.push(...names);
301
+ return () => { this.parameters.length -= names.length; };
302
+ }
254
303
  // ModuleTable: the key a declaration made in the current file is also stored under
255
304
  declaringKey(name) {
256
305
  return this.currentModule && !name.includes('#') ? `${this.currentModule}#${name}` : undefined;
@@ -295,6 +344,7 @@ class ExpressionResolver {
295
344
  this.arrayElementMembers.clear();
296
345
  this.objectVariables.clear();
297
346
  this.objectLiterals.clear();
347
+ this.parameters = [];
298
348
  }
299
349
  /**
300
350
  * Call once every file has been pre-scanned. Captures ran in file order, so one
@@ -451,6 +501,7 @@ class ExpressionResolver {
451
501
  if (unwrappedInit.type === 'ObjectExpression' && Array.isArray(unwrappedInit.properties)) {
452
502
  this.objectLiterals.set(name, unwrappedInit);
453
503
  const map = {};
504
+ const keys = [];
454
505
  for (const p of unwrappedInit.properties) {
455
506
  if (!p || p.type !== 'KeyValueProperty')
456
507
  continue;
@@ -458,6 +509,7 @@ class ExpressionResolver {
458
509
  const keyName = keyNode?.type === 'Identifier' ? keyNode.value : keyNode?.type === 'StringLiteral' ? keyNode.value : undefined;
459
510
  if (!keyName)
460
511
  continue;
512
+ keys.push(keyName);
461
513
  const valExpr = p.value;
462
514
  const vals = this.resolvePossibleStringValuesFromExpression(valExpr);
463
515
  // Only capture properties that we can statically resolve to a single string.
@@ -465,6 +517,8 @@ class ExpressionResolver {
465
517
  map[keyName] = vals[0];
466
518
  }
467
519
  }
520
+ if (keys.length > 0)
521
+ this.sharedObjectKeysTable.set(name, keys);
468
522
  // If at least one property was resolvable, record the partial map.
469
523
  if (Object.keys(map).length > 0) {
470
524
  this.variableTable.set(name, map);
@@ -998,15 +1052,26 @@ class ExpressionResolver {
998
1052
  // if (...) return OrganizationType.CONTRACTOR;
999
1053
  // }
1000
1054
  const exprs = returnType ? [] : this.returnExpressions(fn);
1001
- const vals = returnType
1002
- ? this.resolvePossibleStringValuesFromType(returnType)
1003
- : [...new Set(exprs.flatMap(e => this.resolvePossibleStringValuesFromExpression(e)))];
1055
+ // The body is read inside the function, where its parameters hide the values
1056
+ // declared under their names (#316)
1057
+ const leaveParameters = this.enterParameters(fn);
1058
+ let vals;
1059
+ let refs;
1060
+ try {
1061
+ vals = returnType
1062
+ ? this.resolvePossibleStringValuesFromType(returnType)
1063
+ : [...new Set(exprs.flatMap(e => this.resolvePossibleStringValuesFromExpression(e)))];
1064
+ // A replay has lost the file's local bindings, so it re-resolves only the
1065
+ // return type, or the returned enum / object members and calls of other
1066
+ // functions, kept as small nodes so no function body stays in memory.
1067
+ // It runs outside the function, so none of them may go through a parameter.
1068
+ refs = this.recording ? crossFileRefs(exprs).filter(e => !this.isParameter((e.object ?? e.callee).value)) : [];
1069
+ }
1070
+ finally {
1071
+ leaveParameters();
1072
+ }
1004
1073
  if (vals.length > 0)
1005
1074
  this.variableTable.set(name, vals);
1006
- // A replay has lost the file's local bindings, so it re-resolves only the
1007
- // return type, or the returned enum / object members and calls of other
1008
- // functions, kept as small nodes so no function body stays in memory.
1009
- const refs = this.recording ? crossFileRefs(exprs) : [];
1010
1075
  const store = () => {
1011
1076
  const all = returnType
1012
1077
  ? this.resolvePossibleStringValuesFromType(returnType)
@@ -1137,6 +1202,14 @@ class ExpressionResolver {
1137
1202
  return v;
1138
1203
  return this.sharedObjectMapTable.get(name) ?? this.sharedEnumTable.get(name);
1139
1204
  }
1205
+ /** All keys of an object map, also those whose value is not a string, or of an enum. */
1206
+ getObjectKeys(name) {
1207
+ const keys = this.sharedObjectKeysTable.get(name);
1208
+ if (keys)
1209
+ return keys;
1210
+ const map = this.getObjectMap(name);
1211
+ return map ? Object.keys(map) : undefined;
1212
+ }
1140
1213
  /**
1141
1214
  * Capture a TypeScript enum declaration so members can be resolved later.
1142
1215
  * Accepts SWC node shapes like `TsEnumDeclaration` / `TSEnumDeclaration`.
@@ -1569,15 +1642,9 @@ class ExpressionResolver {
1569
1642
  const exprName = inner.exprName ?? inner.expr ?? inner.entityName;
1570
1643
  const varName = this.typeQueryName(exprName);
1571
1644
  if (varName) {
1572
- // Look up in variableTable (local) or sharedObjectMapTable (cross-file) for object maps
1573
- const v = this.variableTable.get(varName) ?? this.sharedObjectMapTable.get(varName);
1574
- if (v && !Array.isArray(v) && typeof v === 'object') {
1575
- return Object.keys(v);
1576
- }
1577
- // Also check sharedEnumTable (enum keys)
1578
- const ev = this.sharedEnumTable.get(varName);
1579
- if (ev)
1580
- return Object.keys(ev);
1645
+ const keys = this.getObjectKeys(varName);
1646
+ if (keys)
1647
+ return keys;
1581
1648
  }
1582
1649
  }
1583
1650
  }
@@ -1636,4 +1703,5 @@ class ExpressionResolver {
1636
1703
  }
1637
1704
 
1638
1705
  exports.ExpressionResolver = ExpressionResolver;
1706
+ exports.ValueTable = ValueTable;
1639
1707
  exports.nestedMembers = nestedMembers;
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var astUtils = require('./ast-utils.js');
4
+ var expressionResolver = require('./expression-resolver.js');
4
5
 
5
6
  class ScopeManager {
6
7
  scopeStack = [];
@@ -12,20 +13,23 @@ class ScopeManager {
12
13
  // inside class methods.
13
14
  thisFieldStack = [];
14
15
  // Track simple local constants with string literal values to resolve identifier args
15
- simpleConstants = new Map();
16
+ simpleConstants = new expressionResolver.ValueTable(this);
16
17
  // Track simple local constant objects with string literal property values
17
- simpleConstantObjects = new Map();
18
+ simpleConstantObjects = new expressionResolver.ValueTable(this);
18
19
  // `const NS = ['a', 'b']` → used by resolveNsArg for `useTranslation(NS)`.
19
- simpleConstantArrays = new Map();
20
+ simpleConstantArrays = new expressionResolver.ValueTable(this);
20
21
  // `({ ns = 'x' }) =>` / `(ns = 'x') =>` param defaults, set/cleared per function by the visitor.
21
22
  paramDefaults = new Map();
22
23
  // Last-resort identifier resolution for `useTranslation(ns)` (e.g. first member of
23
24
  // a param's union type), wired up by the visitor.
24
25
  identifierFallback;
26
+ // Whether `name` is a parameter of a function being walked, wired up by the visitor. The
27
+ // constant tables are ValueTables: `useTranslation(ns)` in `useT(ns)` is no `const ns` of another file
28
+ isParameter = () => false;
25
29
  // Shared (cross-file) tables so that exported constants from one file can be
26
30
  // resolved when imported in another. These are NOT cleared by reset().
27
- sharedConstants = new Map();
28
- sharedConstantObjects = new Map();
31
+ sharedConstants = new expressionResolver.ValueTable(this);
32
+ sharedConstantObjects = new expressionResolver.ValueTable(this);
29
33
  constructor(config) {
30
34
  this.config = config;
31
35
  }
package/dist/cjs/init.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var inquirer = require('inquirer');
3
+ var prompt = require('./utils/prompt.js');
4
4
  var promises = require('node:fs/promises');
5
5
  var node_path = require('node:path');
6
6
  var heuristicConfig = require('./heuristic-config.js');
@@ -8,10 +8,6 @@ var locizeOnboarding = require('./utils/locize-onboarding.js');
8
8
  var inlangScaffold = require('./utils/inlang-scaffold.js');
9
9
  var agentNote = require('./utils/agent-note.js');
10
10
 
11
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
-
13
- var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
14
-
15
11
  const LOCIZE_SIGNUP_URL = 'https://www.locize.app/register?from=i18next_cli__init-wizard';
16
12
  /**
17
13
  * Determines if the current project is configured as an ESM project.
@@ -177,7 +173,7 @@ async function runInit(options = {}) {
177
173
  answers = { ...defaults, ...given };
178
174
  }
179
175
  else {
180
- answers = { ...given, ...(remaining.length > 0 ? await inquirer__default.default.prompt(remaining) : {}) };
176
+ answers = { ...given, ...(remaining.length > 0 ? await prompt.prompt(remaining) : {}) };
181
177
  }
182
178
  let locizeConfig;
183
179
  const knownProjectId = options.projectId || process.env.LOCIZE_PROJECTID || process.env.LOCIZE_PID;
@@ -4,7 +4,7 @@ var promises = require('node:fs/promises');
4
4
  var glob = require('glob');
5
5
  var node_path = require('node:path');
6
6
  var core = require('@swc/core');
7
- var inquirer = require('inquirer');
7
+ var prompt = require('../../utils/prompt.js');
8
8
  var node_util = require('node:util');
9
9
  var stringDetector = require('./string-detector.js');
10
10
  var transformer = require('./transformer.js');
@@ -16,10 +16,6 @@ var astUtils = require('../../extractor/parsers/ast-utils.js');
16
16
  var fileUtils = require('../../utils/file-utils.js');
17
17
  var messageFormat = require('../../utils/message-format.js');
18
18
 
19
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
-
21
- var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
22
-
23
19
  /**
24
20
  * Main orchestrator for the instrument command.
25
21
  * Scans source files for hardcoded strings and instruments them with i18next calls.
@@ -55,7 +51,7 @@ async function runInstrumenter(config, options, logger$1 = new logger.ConsoleLog
55
51
  let targetNamespace = options.namespace;
56
52
  if (!targetNamespace && options.isInteractive) {
57
53
  const defaultNS = config.extract.defaultNS ?? 'translation';
58
- const { ns } = await inquirer__default.default.prompt([
54
+ const { ns } = await prompt.prompt([
59
55
  {
60
56
  type: 'input',
61
57
  name: 'ns',
@@ -96,7 +92,7 @@ async function runInstrumenter(config, options, logger$1 = new logger.ConsoleLog
96
92
  if (options.isInteractive) {
97
93
  // Ask user about each candidate
98
94
  for (const candidate of candidates) {
99
- const { action } = await inquirer__default.default.prompt([
95
+ const { action } = await prompt.prompt([
100
96
  {
101
97
  type: 'select',
102
98
  name: 'action',
@@ -117,7 +113,7 @@ async function runInstrumenter(config, options, logger$1 = new logger.ConsoleLog
117
113
  candidate.skipReason = 'User skipped';
118
114
  break;
119
115
  case 'edit-key': {
120
- const { key } = await inquirer__default.default.prompt([
116
+ const { key } = await prompt.prompt([
121
117
  {
122
118
  type: 'input',
123
119
  name: 'key',
@@ -129,7 +125,7 @@ async function runInstrumenter(config, options, logger$1 = new logger.ConsoleLog
129
125
  break;
130
126
  }
131
127
  case 'edit-value': {
132
- const { value } = await inquirer__default.default.prompt([
128
+ const { value } = await prompt.prompt([
133
129
  {
134
130
  type: 'input',
135
131
  name: 'value',
@@ -2,8 +2,8 @@
2
2
 
3
3
  var node_util = require('node:util');
4
4
  var promises = require('node:fs/promises');
5
- var execa = require('execa');
6
- var inquirer = require('inquirer');
5
+ var spawn = require('nano-spawn');
6
+ var prompt = require('../utils/prompt.js');
7
7
  var glob = require('glob');
8
8
  var config = require('../config.js');
9
9
  var heuristicConfig = require('../heuristic-config.js');
@@ -26,7 +26,7 @@ var agentPrompt = require('./agent-prompt.js');
26
26
 
27
27
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
28
28
 
29
- var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
29
+ var spawn__default = /*#__PURE__*/_interopDefault(spawn);
30
30
 
31
31
  const LOCIZE_SIGNUP_URL = 'https://www.locize.app/register?from=i18next_cli__localize';
32
32
  const TOTAL_STEPS = 6;
@@ -59,7 +59,7 @@ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
59
59
  */
60
60
  async function isGitTreeDirty() {
61
61
  try {
62
- const { stdout } = await execa.execa('git', ['status', '--porcelain']);
62
+ const { stdout } = await spawn__default.default('git', ['status', '--porcelain']);
63
63
  return stdout.trim().length > 0;
64
64
  }
65
65
  catch {
@@ -241,7 +241,7 @@ async function runLocalize(options = {}, configPath) {
241
241
  }
242
242
  else if (dirty) {
243
243
  if (interactive) {
244
- const { proceed } = await inquirer__default.default.prompt([{
244
+ const { proceed } = await prompt.prompt([{
245
245
  type: 'confirm',
246
246
  name: 'proceed',
247
247
  message: 'Working tree has uncommitted changes. instrument rewrites source files — continue?',
@@ -260,7 +260,7 @@ async function runLocalize(options = {}, configPath) {
260
260
  }
261
261
  // Already-using-i18next heuristic (instrument is idempotent either way)
262
262
  if (stack.hasI18next && stack.initFile && interactive) {
263
- const { proceed } = await inquirer__default.default.prompt([{
263
+ const { proceed } = await prompt.prompt([{
264
264
  type: 'confirm',
265
265
  name: 'proceed',
266
266
  message: `Your project already uses i18next (found ${stack.initFile}). Run instrumentation anyway to catch remaining hardcoded strings?`,
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var execa = require('execa');
3
+ var spawn = require('nano-spawn');
4
4
  var node_util = require('node:util');
5
- var ora = require('ora');
6
- var inquirer = require('inquirer');
5
+ var yoctoSpinner = require('yocto-spinner');
6
+ var prompt = require('./utils/prompt.js');
7
7
  var node_path = require('node:path');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
10
 
11
- var ora__default = /*#__PURE__*/_interopDefault(ora);
12
- var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
11
+ var spawn__default = /*#__PURE__*/_interopDefault(spawn);
12
+ var yoctoSpinner__default = /*#__PURE__*/_interopDefault(yoctoSpinner);
13
13
 
14
14
  /**
15
15
  * Resolves the locize-cli executable to use.
@@ -27,7 +27,7 @@ var inquirer__default = /*#__PURE__*/_interopDefault(inquirer);
27
27
  async function resolveLocizeBin() {
28
28
  // 1. Try a locally / globally installed binary
29
29
  try {
30
- await execa.execa('locize', ['--version']);
30
+ await spawn__default.default('locize', ['--version']);
31
31
  return { cmd: 'locize', prefixArgs: [] };
32
32
  }
33
33
  catch {
@@ -36,7 +36,7 @@ async function resolveLocizeBin() {
36
36
  // 2. Fall back to npx
37
37
  try {
38
38
  console.log(node_util.styleText('yellow', '`locize` command not found – trying npx...'));
39
- await execa.execa('npx', ['locize-cli', '--version']);
39
+ await spawn__default.default('npx', ['locize-cli', '--version']);
40
40
  return { cmd: 'npx', prefixArgs: ['locize-cli'] };
41
41
  }
42
42
  catch {
@@ -68,18 +68,18 @@ async function resolveLocizeBin() {
68
68
  */
69
69
  async function interactiveCredentialSetup(config) {
70
70
  console.log(node_util.styleText('yellow', '\nLocize configuration is missing or invalid. Let\'s set it up!'));
71
- const answers = await inquirer__default.default.prompt([
71
+ const answers = await prompt.prompt([
72
72
  {
73
73
  type: 'input',
74
74
  name: 'projectId',
75
75
  message: 'What is your Locize Project ID? (Find this in your project settings on www.locize.app)',
76
- validate: input => !!input || 'Project ID cannot be empty.',
76
+ validate: (input) => !!input || 'Project ID cannot be empty.',
77
77
  },
78
78
  {
79
79
  type: 'password',
80
80
  name: 'apiKey',
81
81
  message: 'Enter your Locize API key (Project settings → API → API Keys). Any write-capable key works — missing languages are created automatically for new projects.',
82
- validate: input => !!input || 'API Key cannot be empty.',
82
+ validate: (input) => !!input || 'API Key cannot be empty.',
83
83
  },
84
84
  {
85
85
  type: 'input',
@@ -92,7 +92,7 @@ async function interactiveCredentialSetup(config) {
92
92
  console.error(node_util.styleText('red', 'Project ID is required to continue.'));
93
93
  return undefined;
94
94
  }
95
- const { save } = await inquirer__default.default.prompt([{
95
+ const { save } = await prompt.prompt([{
96
96
  type: 'confirm',
97
97
  name: 'save',
98
98
  message: 'Would you like to see how to save these credentials for future use?',
@@ -177,7 +177,7 @@ function maskArgs(args) {
177
177
  });
178
178
  }
179
179
  /**
180
- * Helper function to build the array of arguments for the execa call.
180
+ * Helper function to build the array of arguments for the spawn call.
181
181
  * This ensures the logic is consistent for both the initial run and the retry.
182
182
  */
183
183
  function buildArgs(command, config, cliOptions) {
@@ -332,14 +332,14 @@ async function runLocizeCommand(command, config, cliOptions = {}) {
332
332
  return;
333
333
  }
334
334
  const { cmd, prefixArgs } = resolved;
335
- const spinner = ora__default.default(`Running 'locize ${command}'...\n`).start();
335
+ const spinner = yoctoSpinner__default.default({ text: `Running 'locize ${command}'...\n` }).start();
336
336
  let effectiveConfig = config;
337
337
  try {
338
338
  // 1. First attempt
339
339
  const initialArgs = [...prefixArgs, ...buildArgs(command, effectiveConfig, cliOptions)];
340
340
  console.log(node_util.styleText('cyan', `\nRunning 'locize ${maskArgs(initialArgs.slice(prefixArgs.length)).join(' ')}'...`));
341
- const result = await execa.execa(cmd, initialArgs, { stdio: 'pipe' });
342
- spinner.succeed(node_util.styleText('green', `'locize ${command}' completed successfully.`));
341
+ const result = await spawn__default.default(cmd, initialArgs, { stdio: 'pipe' });
342
+ spinner.success(node_util.styleText('green', `'locize ${command}' completed successfully.`));
343
343
  if (result?.stdout)
344
344
  console.log(result.stdout); // Print captured output on success
345
345
  }
@@ -348,7 +348,7 @@ async function runLocizeCommand(command, config, cliOptions = {}) {
348
348
  if (throwOnError) {
349
349
  // Orchestrating callers (e.g. `localize`) handle credentials and
350
350
  // messaging themselves — no interactive retry, no process.exit.
351
- spinner.fail(node_util.styleText('red', `Error executing 'locize ${command}'.`));
351
+ spinner.error(node_util.styleText('red', `Error executing 'locize ${command}'.`));
352
352
  throw new LocizeCommandError(stderr || error.stdout || error.message, { stdout: error.stdout, stderr });
353
353
  }
354
354
  if (stderr.includes('missing required argument')) {
@@ -362,25 +362,25 @@ async function runLocizeCommand(command, config, cliOptions = {}) {
362
362
  // 3. Retry attempt, rebuilding args with the NOW-UPDATED currentConfig object
363
363
  const retryArgs = [...prefixArgs, ...buildArgs(command, effectiveConfig, cliOptions)];
364
364
  console.log(node_util.styleText('cyan', `\nRunning 'locize ${maskArgs(retryArgs.slice(prefixArgs.length)).join(' ')}'...`));
365
- const result = await execa.execa(cmd, retryArgs, { stdio: 'pipe' });
366
- spinner.succeed(node_util.styleText('green', 'Retry successful!'));
365
+ const result = await spawn__default.default(cmd, retryArgs, { stdio: 'pipe' });
366
+ spinner.success(node_util.styleText('green', 'Retry successful!'));
367
367
  if (result?.stdout)
368
368
  console.log(result.stdout);
369
369
  }
370
370
  catch (retryError) {
371
- spinner.fail(node_util.styleText('red', 'Error during retry.'));
371
+ spinner.error(node_util.styleText('red', 'Error during retry.'));
372
372
  console.error(retryError.stderr || retryError.message);
373
373
  process.exit(1);
374
374
  }
375
375
  }
376
376
  else {
377
- spinner.fail('Operation cancelled.');
377
+ spinner.error('Operation cancelled.');
378
378
  process.exit(1); // User aborted the prompt
379
379
  }
380
380
  }
381
381
  else {
382
382
  // Handle other errors
383
- spinner.fail(node_util.styleText('red', `Error executing 'locize ${command}'.`));
383
+ spinner.error(node_util.styleText('red', `Error executing 'locize ${command}'.`));
384
384
  console.error(stderr || error.message);
385
385
  process.exit(1);
386
386
  }