@uxf/scripts 10.0.0-beta.49 → 10.0.0-beta.57
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
|
@@ -3,22 +3,24 @@ const { argv, env } = require("process");
|
|
|
3
3
|
module.exports = async () => {
|
|
4
4
|
const cli = require("yargs")
|
|
5
5
|
.command("$0", "UXF i18n namespaces generator", (yargs) => {
|
|
6
|
-
yargs.demandCommand(0, 0).usage(`
|
|
7
|
-
Usage:
|
|
6
|
+
yargs.demandCommand(0, 0).usage(`
|
|
7
|
+
Usage:
|
|
8
8
|
uxf-i18n-namespaces-gen [options]`);
|
|
9
9
|
})
|
|
10
|
-
.option("
|
|
10
|
+
.option("i", { alias: "include", array: true, default: [] })
|
|
11
|
+
.option("o", { alias: "output", default: "i18n-pages.json" })
|
|
12
|
+
.option("h", { alias: "help" })
|
|
11
13
|
.strict(false)
|
|
12
14
|
.exitProcess(false);
|
|
13
15
|
|
|
14
16
|
try {
|
|
15
|
-
const { help,
|
|
17
|
+
const { help, include, output } = cli.parse(argv.slice(2));
|
|
16
18
|
|
|
17
19
|
if (Boolean(help)) {
|
|
18
20
|
return 0;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
await require("./index");
|
|
23
|
+
await require("./index")(include, output);
|
|
22
24
|
} catch (e) {
|
|
23
25
|
console.error(e);
|
|
24
26
|
return 1;
|
|
@@ -71,10 +71,10 @@ const filePathToRoute = (filePath) => {
|
|
|
71
71
|
return removeTrailingSlash(route);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
function main() {
|
|
74
|
+
function main(includes, output) {
|
|
75
75
|
// Negative lookahead – ignore searching for any files
|
|
76
76
|
// that aren't part of our include list
|
|
77
|
-
const searchDirs = new RegExp(`^(?!(${INCLUDE.join("|")}))`, "i");
|
|
77
|
+
const searchDirs = new RegExp(`^(?!(${[...INCLUDE, includes].join("|")}))`, "i");
|
|
78
78
|
|
|
79
79
|
const pages = walk("src/pages").flat(Number.POSITIVE_INFINITY);
|
|
80
80
|
|
|
@@ -108,14 +108,10 @@ function main() {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
writeFileSync(path.resolve(process.cwd(),
|
|
111
|
+
writeFileSync(path.resolve(process.cwd(), output), JSON.stringify(result, null, 4));
|
|
112
112
|
|
|
113
113
|
console.log("Namespaces generated!");
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
main();
|
|
119
|
-
} catch (e) {
|
|
120
|
-
console.error("Error:", e);
|
|
121
|
-
}
|
|
117
|
+
module.exports = main;
|
|
@@ -25,4 +25,20 @@ describe("find namespaces in t functions", function () {
|
|
|
25
25
|
"in-translation-parameter",
|
|
26
26
|
]);
|
|
27
27
|
});
|
|
28
|
+
|
|
29
|
+
it("should ignore old translations (without namespace)", function () {
|
|
30
|
+
expect(
|
|
31
|
+
findTFunctionNamespaces(`
|
|
32
|
+
if (minutesDiff === 0) {
|
|
33
|
+
return t("datetime.format.rightNow");
|
|
34
|
+
} else if (minutesDiff > 0 && minutesDiff < 60) {
|
|
35
|
+
return t("datetime.format.beforeMinutes", { count: minutesDiff });
|
|
36
|
+
} else if (hoursDiff > 0 && hoursDiff < 24) {
|
|
37
|
+
return t("datetime.format.beforeHours", { count: hoursDiff });
|
|
38
|
+
} else if (daysDiff === 1) {
|
|
39
|
+
return t("datetime.format.yesterdayAt", { time: date.format("LT") });
|
|
40
|
+
}
|
|
41
|
+
`),
|
|
42
|
+
).toStrictEqual([]);
|
|
43
|
+
});
|
|
28
44
|
});
|