i18nizer 0.1.1 → 0.1.2

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.
@@ -1,7 +1,25 @@
1
- import { Project } from "ts-morph";
1
+ import fs from "node:fs";
2
+ import { Project, ts } from "ts-morph";
3
+ /**
4
+ * Parse a TSX/JSX file using ts-morph
5
+ * Works with any absolute or relative path
6
+ */
2
7
  export function parseFile(filePath) {
8
+ if (!fs.existsSync(filePath)) {
9
+ throw new Error(`File not found: ${filePath}`);
10
+ }
11
+ // Create a completely empty Project
3
12
  const project = new Project({
4
- tsConfigFilePath: "tsconfig.json",
13
+ compilerOptions: {
14
+ allowJs: true,
15
+ esModuleInterop: true,
16
+ jsx: ts.JsxEmit.React,
17
+ skipLibCheck: true,
18
+ strict: false,
19
+ target: 3 // ES2022
20
+ },
21
+ useInMemoryFileSystem: false
5
22
  });
23
+ // Add only the single file
6
24
  return project.addSourceFileAtPath(filePath);
7
25
  }
@@ -1,6 +1,8 @@
1
1
  import chalk from "chalk";
2
2
  import fs from "node:fs";
3
+ import os from "node:os";
3
4
  import path from "node:path";
5
+ const CONFIG_DIR = path.join(os.homedir(), ".i18nizer", "messages");
4
6
  export function writeLocaleFiles(namespace, data, locales) {
5
7
  for (const locale of locales) {
6
8
  const content = {};
@@ -8,7 +10,7 @@ export function writeLocaleFiles(namespace, data, locales) {
8
10
  for (const key of Object.keys(data[namespace])) {
9
11
  content[namespace][key] = data[namespace][key][locale];
10
12
  }
11
- const dir = path.join(process.cwd(), "messages", locale);
13
+ const dir = path.join(CONFIG_DIR, locale);
12
14
  fs.mkdirSync(dir, { recursive: true });
13
15
  const filePath = path.join(dir, `${namespace}.json`);
14
16
  fs.writeFileSync(filePath, JSON.stringify(content, null, 2));
@@ -161,5 +161,5 @@
161
161
  ]
162
162
  }
163
163
  },
164
- "version": "0.1.1"
164
+ "version": "0.1.2"
165
165
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "i18nizer",
3
3
  "description": "CLI to extract texts from JSX/TSX and generate i18n JSON with AI translations",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "author": "Yoannis Sanchez Soto",
6
6
  "bin": "./bin/run.js",
7
7
  "bugs": "https://github.com/tools/i18nizer/issues",