ai-localize-codemods 2.0.7 → 3.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.
- package/CHANGELOG.md +15 -0
- package/dist/index.js +6 -4
- package/dist/index.mjs +4 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
# ai-localize-codemods
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- bug fixes
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- ai-localize-shared@3.0.0
|
|
13
|
+
|
|
3
14
|
## 2.0.7
|
|
4
15
|
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **`@babel/traverse` / `@babel/generator` CJS/ESM interop** — Added runtime shims in `react-codemod.ts` so the bundled CLI no longer throws `(0 , import_traverse.default) is not a function` when applying React codemods.
|
|
19
|
+
|
|
5
20
|
### Patch Changes
|
|
6
21
|
|
|
7
22
|
- Added `repository`, `homepage`, `bugs`, `author` fields to `package.json` for npm registry display.
|
package/dist/index.js
CHANGED
|
@@ -50,6 +50,8 @@ var parser = __toESM(require("@babel/parser"));
|
|
|
50
50
|
var import_traverse = __toESM(require("@babel/traverse"));
|
|
51
51
|
var import_generator = __toESM(require("@babel/generator"));
|
|
52
52
|
var t = __toESM(require("@babel/types"));
|
|
53
|
+
var traverse = import_traverse.default.default ?? import_traverse.default;
|
|
54
|
+
var generate = import_generator.default.default ?? import_generator.default;
|
|
53
55
|
var DEFAULT_IMPORT_PACKAGE = "react-i18next";
|
|
54
56
|
var DEFAULT_HOOK_NAME = "useTranslation";
|
|
55
57
|
var DEFAULT_TRANSLATION_FN = "t";
|
|
@@ -136,7 +138,7 @@ var ReactCodemod = class {
|
|
|
136
138
|
}
|
|
137
139
|
return t.callExpression(t.identifier(translationFn), [t.stringLiteral(key)]);
|
|
138
140
|
};
|
|
139
|
-
(
|
|
141
|
+
traverse(ast, {
|
|
140
142
|
ImportDeclaration(nodePath2) {
|
|
141
143
|
if (nodePath2.node.source.value === importSpecifier2) {
|
|
142
144
|
hasImport = true;
|
|
@@ -151,7 +153,7 @@ var ReactCodemod = class {
|
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
});
|
|
154
|
-
(
|
|
156
|
+
traverse(ast, {
|
|
155
157
|
JSXText(nodePath2) {
|
|
156
158
|
const text = nodePath2.node.value.trim();
|
|
157
159
|
if (!text) return;
|
|
@@ -203,7 +205,7 @@ var ReactCodemod = class {
|
|
|
203
205
|
this.injectHook(ast);
|
|
204
206
|
injectedHook = true;
|
|
205
207
|
}
|
|
206
|
-
const output = (
|
|
208
|
+
const output = generate(
|
|
207
209
|
ast,
|
|
208
210
|
{ retainLines: false, comments: true, compact: false },
|
|
209
211
|
this.content
|
|
@@ -222,7 +224,7 @@ var ReactCodemod = class {
|
|
|
222
224
|
const hookName = this.hookName;
|
|
223
225
|
const translationFn = this.translationFn;
|
|
224
226
|
const namespace = this.namespace;
|
|
225
|
-
(
|
|
227
|
+
traverse(ast, {
|
|
226
228
|
FunctionDeclaration(nodePath2) {
|
|
227
229
|
if (!isReactComponent(nodePath2.node.id?.name)) return;
|
|
228
230
|
injectHookIntoBody(nodePath2.node.body, hookName, translationFn, namespace);
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as nodePath from "path";
|
|
4
4
|
import * as parser from "@babel/parser";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import _traverse from "@babel/traverse";
|
|
6
|
+
import _generate from "@babel/generator";
|
|
7
7
|
import * as t from "@babel/types";
|
|
8
|
+
var traverse = _traverse.default ?? _traverse;
|
|
9
|
+
var generate = _generate.default ?? _generate;
|
|
8
10
|
var DEFAULT_IMPORT_PACKAGE = "react-i18next";
|
|
9
11
|
var DEFAULT_HOOK_NAME = "useTranslation";
|
|
10
12
|
var DEFAULT_TRANSLATION_FN = "t";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-localize-codemods",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "AST-based codemods to inject i18n wrappers into frontend source code",
|
|
5
5
|
"author": "ai-localize-core contributors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@babel/generator": "^7.23.9",
|
|
54
54
|
"recast": "^0.23.4",
|
|
55
55
|
"jscodeshift": "^0.15.2",
|
|
56
|
-
"ai-localize-shared": "
|
|
56
|
+
"ai-localize-shared": "3.0.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/babel__generator": "^7.6.8",
|