lingo.dev 0.94.6 → 0.96.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/build/cli.cjs +133 -87
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +66 -20
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -1855,42 +1855,50 @@ function createAndroidLoader() {
|
|
|
1855
1855
|
import { parse } from "csv-parse/sync";
|
|
1856
1856
|
import { stringify } from "csv-stringify/sync";
|
|
1857
1857
|
import _11 from "lodash";
|
|
1858
|
+
function detectKeyColumnName(csvString) {
|
|
1859
|
+
const row = parse(csvString)[0];
|
|
1860
|
+
const firstColumn = row?.[0]?.trim();
|
|
1861
|
+
return firstColumn || "KEY";
|
|
1862
|
+
}
|
|
1858
1863
|
function createCsvLoader() {
|
|
1864
|
+
return composeLoaders(_createCsvLoader(), createPullOutputCleaner());
|
|
1865
|
+
}
|
|
1866
|
+
function _createCsvLoader() {
|
|
1859
1867
|
return createLoader({
|
|
1860
|
-
async pull(locale,
|
|
1861
|
-
const
|
|
1868
|
+
async pull(locale, input2) {
|
|
1869
|
+
const keyColumnName = detectKeyColumnName(input2.split("\n").find((l) => l.length));
|
|
1870
|
+
const inputParsed = parse(input2, {
|
|
1862
1871
|
columns: true,
|
|
1863
1872
|
skip_empty_lines: true,
|
|
1864
1873
|
relax_column_count_less: true
|
|
1865
1874
|
});
|
|
1866
|
-
const
|
|
1867
|
-
_11.forEach(
|
|
1868
|
-
const key = row
|
|
1875
|
+
const items = {};
|
|
1876
|
+
_11.forEach(inputParsed, (row) => {
|
|
1877
|
+
const key = row[keyColumnName];
|
|
1869
1878
|
if (key && row[locale] && row[locale].trim() !== "") {
|
|
1870
|
-
|
|
1879
|
+
items[key] = row[locale];
|
|
1871
1880
|
}
|
|
1872
1881
|
});
|
|
1873
|
-
return
|
|
1882
|
+
return {
|
|
1883
|
+
inputParsed,
|
|
1884
|
+
keyColumnName,
|
|
1885
|
+
items
|
|
1886
|
+
};
|
|
1874
1887
|
},
|
|
1875
|
-
async push(locale,
|
|
1876
|
-
const
|
|
1877
|
-
columns: true,
|
|
1878
|
-
skip_empty_lines: true,
|
|
1879
|
-
relax_column_count_less: true
|
|
1880
|
-
});
|
|
1881
|
-
const columns = input2.length > 0 ? Object.keys(input2[0]) : ["id", locale];
|
|
1888
|
+
async push(locale, { inputParsed, keyColumnName, items }) {
|
|
1889
|
+
const columns = inputParsed.length > 0 ? Object.keys(inputParsed[0]) : [keyColumnName, locale];
|
|
1882
1890
|
if (!columns.includes(locale)) {
|
|
1883
1891
|
columns.push(locale);
|
|
1884
1892
|
}
|
|
1885
|
-
const updatedRows =
|
|
1893
|
+
const updatedRows = inputParsed.map((row) => ({
|
|
1886
1894
|
...row,
|
|
1887
|
-
[locale]:
|
|
1895
|
+
[locale]: items[row[keyColumnName]] || row[locale] || ""
|
|
1888
1896
|
}));
|
|
1889
|
-
const existingKeys = new Set(
|
|
1890
|
-
Object.entries(
|
|
1897
|
+
const existingKeys = new Set(inputParsed.map((row) => row[keyColumnName]));
|
|
1898
|
+
Object.entries(items).forEach(([key, value]) => {
|
|
1891
1899
|
if (!existingKeys.has(key)) {
|
|
1892
1900
|
const newRow = {
|
|
1893
|
-
|
|
1901
|
+
[keyColumnName]: key,
|
|
1894
1902
|
...Object.fromEntries(columns.map((column) => [column, ""]))
|
|
1895
1903
|
};
|
|
1896
1904
|
newRow[locale] = value;
|
|
@@ -1904,6 +1912,16 @@ function createCsvLoader() {
|
|
|
1904
1912
|
}
|
|
1905
1913
|
});
|
|
1906
1914
|
}
|
|
1915
|
+
function createPullOutputCleaner() {
|
|
1916
|
+
return createLoader({
|
|
1917
|
+
async pull(_locale, input2) {
|
|
1918
|
+
return input2.items;
|
|
1919
|
+
},
|
|
1920
|
+
async push(_locale, data, _oI, _oL, pullInput) {
|
|
1921
|
+
return { ...pullInput, items: data };
|
|
1922
|
+
}
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1907
1925
|
|
|
1908
1926
|
// src/cli/loaders/html.ts
|
|
1909
1927
|
import { JSDOM } from "jsdom";
|
|
@@ -6152,6 +6170,23 @@ var flagsSchema2 = z2.object({
|
|
|
6152
6170
|
|
|
6153
6171
|
// src/cli/cmd/run/index.ts
|
|
6154
6172
|
import chalk13 from "chalk";
|
|
6173
|
+
|
|
6174
|
+
// src/cli/cmd/run/_utils.ts
|
|
6175
|
+
async function determineAuthId(ctx) {
|
|
6176
|
+
const isByokMode = !!ctx.config?.provider;
|
|
6177
|
+
if (isByokMode) {
|
|
6178
|
+
return null;
|
|
6179
|
+
} else {
|
|
6180
|
+
try {
|
|
6181
|
+
const authStatus = await ctx.localizer?.checkAuth();
|
|
6182
|
+
return authStatus?.username || null;
|
|
6183
|
+
} catch {
|
|
6184
|
+
return null;
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
|
|
6189
|
+
// src/cli/cmd/run/index.ts
|
|
6155
6190
|
var run_default = new Command16().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
|
|
6156
6191
|
"--source-locale <source-locale>",
|
|
6157
6192
|
"Locale to use as source locale. Defaults to i18n.json locale.source",
|
|
@@ -6208,6 +6243,7 @@ var run_default = new Command16().command("run").description("Run Lingo.dev loca
|
|
|
6208
6243
|
"Number of concurrent tasks to run",
|
|
6209
6244
|
(val) => parseInt(val)
|
|
6210
6245
|
).action(async (args) => {
|
|
6246
|
+
let authId = null;
|
|
6211
6247
|
try {
|
|
6212
6248
|
const ctx = {
|
|
6213
6249
|
flags: flagsSchema2.parse(args),
|
|
@@ -6223,6 +6259,11 @@ var run_default = new Command16().command("run").description("Run Lingo.dev loca
|
|
|
6223
6259
|
await renderHero();
|
|
6224
6260
|
await renderSpacer();
|
|
6225
6261
|
await setup(ctx);
|
|
6262
|
+
authId = await determineAuthId(ctx);
|
|
6263
|
+
trackEvent(authId, "cmd.run.start", {
|
|
6264
|
+
config: ctx.config,
|
|
6265
|
+
flags: ctx.flags
|
|
6266
|
+
});
|
|
6226
6267
|
await renderSpacer();
|
|
6227
6268
|
await plan(ctx);
|
|
6228
6269
|
await renderSpacer();
|
|
@@ -6230,7 +6271,12 @@ var run_default = new Command16().command("run").description("Run Lingo.dev loca
|
|
|
6230
6271
|
await renderSpacer();
|
|
6231
6272
|
await renderSummary(ctx.results);
|
|
6232
6273
|
await renderSpacer();
|
|
6274
|
+
trackEvent(authId, "cmd.run.success", {
|
|
6275
|
+
config: ctx.config,
|
|
6276
|
+
flags: ctx.flags
|
|
6277
|
+
});
|
|
6233
6278
|
} catch (error) {
|
|
6279
|
+
trackEvent(authId || "unknown", "cmd.run.error", {});
|
|
6234
6280
|
process.exit(1);
|
|
6235
6281
|
}
|
|
6236
6282
|
});
|
|
@@ -7439,7 +7485,7 @@ async function renderHero2() {
|
|
|
7439
7485
|
// package.json
|
|
7440
7486
|
var package_default = {
|
|
7441
7487
|
name: "lingo.dev",
|
|
7442
|
-
version: "0.
|
|
7488
|
+
version: "0.96.0",
|
|
7443
7489
|
description: "Lingo.dev CLI",
|
|
7444
7490
|
private: false,
|
|
7445
7491
|
publishConfig: {
|