yata-fetch 2.1.6 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yata-fetch",
3
- "version": "2.1.6",
3
+ "version": "2.2.0",
4
4
  "packageManager": "pnpm@10.4.1",
5
5
  "type": "module",
6
6
  "description": "Adds CLI interface for importing translation files from Yata",
@@ -21,6 +21,7 @@
21
21
  "bin": "./bin/yata-fetch.js",
22
22
  "scripts": {
23
23
  "build": "vite build",
24
+ "prepare": "vite build",
24
25
  "generate": "node bin/yata-fetch.js --config test/fixtures/yata.json",
25
26
  "test": "vitest run",
26
27
  "coverage": "vitest run --coverage",
@@ -33,21 +34,21 @@
33
34
  "nconf": "0.13.0"
34
35
  },
35
36
  "devDependencies": {
36
- "@eslint/js": "9.39.2",
37
+ "@eslint/js": "10.0.1",
37
38
  "@types/nconf": "0.10.7",
38
- "@types/node": "25.2.0",
39
- "@typescript-eslint/eslint-plugin": "8.54.0",
40
- "@typescript-eslint/parser": "8.54.0",
41
- "@vitest/coverage-v8": "4.0.18",
42
- "c8": "10.1.3",
43
- "eslint": "9.39.2",
44
- "globals": "17.3.0",
39
+ "@types/node": "25.6.0",
40
+ "@typescript-eslint/eslint-plugin": "8.59.1",
41
+ "@typescript-eslint/parser": "8.59.1",
42
+ "@vitest/coverage-v8": "4.1.5",
43
+ "c8": "11.0.0",
44
+ "eslint": "10.2.1",
45
+ "globals": "17.5.0",
45
46
  "npm-run-all": "4.1.5",
46
- "prettier": "3.8.1",
47
- "typescript": "^5.9.3",
48
- "typescript-eslint": "8.54.0",
49
- "vite": "^7.3.1",
50
- "vitest": "4.0.18"
47
+ "prettier": "3.8.3",
48
+ "typescript": "^6.0.3",
49
+ "typescript-eslint": "8.59.1",
50
+ "vite": "^8.0.10",
51
+ "vitest": "4.1.5"
51
52
  },
52
53
  "pnpm": {
53
54
  "onlyBuiltDependencies": [
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "useDefineForClassFields": true,
5
5
  "module": "ESNext",
6
6
  "lib": ["ESNext", "DOM"],
7
- "moduleResolution": "Node",
7
+ "moduleResolution": "bundler",
8
8
  "strict": true,
9
9
  "sourceMap": true,
10
10
  "resolveJsonModule": true,
@@ -14,7 +14,8 @@
14
14
  "noUnusedLocals": true,
15
15
  "noUnusedParameters": true,
16
16
  "noImplicitReturns": true,
17
- "skipLibCheck": true
17
+ "skipLibCheck": true,
18
+ "types": ["node"]
18
19
  },
19
20
  "include": ["src"]
20
21
  }
package/dist/cli.cjs DELETED
@@ -1,2 +0,0 @@
1
- "use strict";function c(t,i){let e;switch(t){case"red":e="\x1B[31m";break;case"green":e="\x1B[32m";break;case"yellow":e="\x1B[33m";break;default:e="\x1B[37m"}return console.log(`${e}%s\x1B[0m`,i)}const y=require("https"),m=require("path"),l=require("fs"),f={config:null,defaultConfigPath:"./yata.json",configPath:"",token:"",project:"",locales:[],format:"yml",root:!1,outputPath:"translations",stripEmpty:!1,apiHost:"",getConfigPath(t){return t?this.configPath=t:this.configPath=this.defaultConfigPath,this.configPath},validateConfig(t,i,e,n,h,s,a){if(t)this.token=t;else throw new Error("No `token` in ENV");if(i)this.project=i;else throw new Error("No `project` in config file");if(!Array.isArray(e)||e.length===0)throw new Error("No `locales` in config file");return this.locales=e,n&&typeof n=="string"&&(this.format=n),h&&typeof h=="boolean"&&(this.root=h),s&&typeof s=="string"&&(this.outputPath=s),a&&typeof a=="boolean"&&(this.stripEmpty=a),!0},normalizeLocale(t){if(!t)return;const i=t.replace("-","_").split("_"),e=[];return e.push(i[0].toLowerCase()),i[1]&&e.push(i[1].toUpperCase()),e.join("_")},downloadTranslation(t){const i=this.normalizeLocale(t);if(!i)throw new Error("No locale passed to download function");l.existsSync(this.outputPath)||l.mkdirSync(this.outputPath);const e=`${i}.${this.format}`,n=m.join(process.cwd(),`${this.outputPath}/${e}`),h=`${this.apiHost}/api/v1/project/${this.project}/${t}/${this.format}?apiToken=${this.token}&root=${this.root}&strip_empty=${this.stripEmpty}`;let s;l.existsSync(n)&&(s=l.readFileSync(n));const a=l.createWriteStream(n);return new Promise((g,u)=>{y.get(h,r=>{const{statusCode:p}=r;if(p!==200)return u(`Request Failed.
2
- Status Code: ${p}`);r.pipe(a),a.on("finish",()=>{const d=l.readFileSync(n);s&&s.equals(d)?c("yellow",`Generating "${t}" translation. Skipped.`):c("green",`Generating "${t}" translation. Done.`),g(!0)})}).on("error",r=>{r instanceof Error?c("red",r.message):typeof r=="string"&&c("red",r)})})}},o=require("nconf");async function w(){o.argv(),o.env(),o.file({file:f.getConfigPath(o.get("config"))}),f.apiHost=o.get("YATA_API_HOST")||"https://api.yatapp.net";try{if(f.validateConfig(o.get(o.get("token")),o.get("project"),o.get("locales"),o.get("format"),o.get("root"),o.get("outputPath"),o.get("strip_empty")))if(o.get("locale"))await f.downloadTranslation(o.get("locale"));else for(const t of f.locales)await f.downloadTranslation(t)}catch(t){t instanceof Error?c("red",t.message):typeof t=="string"&&c("red",t)}}module.exports=w;