ai-localize-codemods 2.0.6 → 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 +23 -0
- package/LICENSE +21 -0
- package/dist/index.js +6 -4
- package/dist/index.mjs +4 -2
- package/package.json +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
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
|
+
|
|
14
|
+
## 2.0.7
|
|
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
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Added `repository`, `homepage`, `bugs`, `author` fields to `package.json` for npm registry display.
|
|
23
|
+
- Added `sideEffects: false` to enable tree-shaking in bundlers.
|
|
24
|
+
- Added `prepublishOnly` script to ensure the package is built before publishing.
|
|
25
|
+
|
|
3
26
|
## 2.0.6
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 ai-localize-core contributors
|
|
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.
|
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,10 +1,22 @@
|
|
|
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
|
+
"author": "ai-localize-core contributors",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/ai-localize/ai-localize-core.git",
|
|
10
|
+
"directory": "packages/codemods"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/ai-localize/ai-localize-core/tree/main/packages/codemods#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ai-localize/ai-localize-core/issues"
|
|
15
|
+
},
|
|
5
16
|
"main": "./dist/index.js",
|
|
6
17
|
"module": "./dist/index.mjs",
|
|
7
18
|
"types": "./dist/index.d.ts",
|
|
19
|
+
"sideEffects": false,
|
|
8
20
|
"files": [
|
|
9
21
|
"dist",
|
|
10
22
|
"README.md",
|
|
@@ -41,7 +53,7 @@
|
|
|
41
53
|
"@babel/generator": "^7.23.9",
|
|
42
54
|
"recast": "^0.23.4",
|
|
43
55
|
"jscodeshift": "^0.15.2",
|
|
44
|
-
"ai-localize-shared": "
|
|
56
|
+
"ai-localize-shared": "3.0.0"
|
|
45
57
|
},
|
|
46
58
|
"devDependencies": {
|
|
47
59
|
"@types/babel__generator": "^7.6.8",
|
|
@@ -51,7 +63,6 @@
|
|
|
51
63
|
"typescript": "^5.3.3",
|
|
52
64
|
"vitest": "^1.2.1"
|
|
53
65
|
},
|
|
54
|
-
"license": "MIT",
|
|
55
66
|
"publishConfig": {
|
|
56
67
|
"access": "public"
|
|
57
68
|
},
|